Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cross-Origin Request Blocked #353

Closed
Nahasean94 opened this issue Apr 17, 2018 · 4 comments
Closed

Cross-Origin Request Blocked #353

Nahasean94 opened this issue Apr 17, 2018 · 4 comments

Comments

@Nahasean94
Copy link

Am trying to serve built react code and connect to a nodejs server. I have serve running on port 5000 and node backend on port 8080. I have enabled cors on the node server, and it works fine with the default react server that runs on port 3000 when you create a react app. But when I build the react app and serve the front end code with the serve module, the browser throws the error that 'Cross-Origin Request Blocked:...'. I have tried adding options by running the following commands but it wont work.

  1. serve --cors -s build
  2. serve -C -s build

Anyone with an idea how to enable cors in this module?

@leo
Copy link
Contributor

leo commented May 28, 2018

Thank you for the effort you've put into this!

This is now possible by supplying a serve.json file. All thanks to serve-handler, as described in the notes for the new release.

Simply add headers to your config file, as described in the serve-handler documentation.

@leo leo closed this as completed May 28, 2018
@crhistianramirez
Copy link

FYI serve --cors was added back in December 2019

@vamseekrishna25
Copy link

having the same problem --cors is not working any solution to it?

@raquelhortab
Copy link

same here, even with the --cors option, I get cors errors. I am serving a flutter app that accesses an api on a different domain

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants