Next.js Discord

Discord Forum

How to bypass CORS Next-JS locally for testing

Unanswered
Asian black bear posted this in #help-forum
Open in Discord
Asian black bearOP
I'm trying to build a local build a server where it's mandatory to upload images.
whenever I try to upload on the local host I get
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://xxx.xxx.xxx.xxx:6001/media/upload. (Reason: CORS request did not succeed). Status code: (null).

The same goes for Chrome and Firefox.

I'm using
Fake-REST-server : hosted by local-ssl-proxy on 6000 to 6001
Next-js : hosted by local-ssl-proxy on 3000 to 3001


to bypass cors I've tried 2 Firefox extensions
1 - CORS Everywhere
2- Allow CORS: Access-Control-Allow-Origin

they're both on and they're both not doing anything.

Why is it so hard to just test something ?

Help!!

7 Replies

2 Ways:
- Your api must send proper CORS headers to the browser(recommended)
- Instead of uploading the image client side to the API, send it to your nextjs server and upload it server side, bypassing cors(not recommended)
@Yi Lon Ma 2 Ways: - Your api must send proper CORS headers to the browser(recommended) - Instead of uploading the image client side to the API, send it to your nextjs server and upload it server side, bypassing cors(not recommended)
Asian black bearOP
I think I'm already sending a proper CORS, but the issue is The Same Origin Policy.

But, could you give me an example of a proper CORS that worked for you just to compare ?
express got cors
hono got hono/cors
you should check one out
The Same Origin Policy
which is just... CORS. your backend did not send proper CORS headers