Getting CORS error while uploading video using API jQuery

Access to XMLHttpRequest at ‹ https://domain.com/api/v1/videos/upload › from origin ‹ https://domain2.com › has been blocked by CORS policy: Response to preflight request doesn’t pass access control check: It does not have HTTP ok status.

I have installed Peertube with docker.

Can you please help me with this issue?

This is a browser security mecanism. More informations here:

How to fix using fetch?

I just checked Peertube code. Unless I missread something, cross domain calls are authorized on API endpoints.
So maybe you just have to add the crossDomain: true parameter to your jQuery call.

I have tried also with crossDomain: true parameter but still the same error.

In your browser developer tools, in the «network» tab, can you see any request using the OPTIONS method? (request to the upload API endpoint)
If so, is this request ok or not?

Is it possible to share your Peertube instance url, so we can check that there is no configuration error, by trying some cross-domain request by ourselves?

Screenshot 2022-12-15 135807

I can see two requests here.

Peertube instance url : upcast.work

I did some tests. It seems I missed something in the Peertube code. It seems that cross-domain requests are not allowed for API access points.
I don’t have time to look into this further. I’ll let someone else answer.

How I can fix the issue?
Do you have any idea I can make update the code if you give me a guide?

Thank you.

As I said, I have no time to dig this.

Can you describe your project (and perhaps share your code?), so that other people reading this post can help?

Does upcast.work belong to you? Is this the only server on which you want to upload? If so, you can try to change some nginx configuration to change CORS response on specific endpoints. CORS is explained in detail in my first link. For Nginx configuration, please reffer to the nginx documentation.
This is not an easy development, it can’t be easily answered on a forum.

Yes, That domain belongs to me.

I am trying to upload videos through API from a different domain to upcast.work.

I have referred to CORS and Nginx documentation that I have updated the configuration according to it. but still have the same error.

That will be great if you will provide me with a solution.

Thank you.

Any solutions for that?