Zouari Moez
Zouari Moez

Reputation: 73

Deploy React Application

I want to make my application in production so I created a build folder and when I follow the steps in React deployment documentation I'm facing the problem

Access to XMLHttpRequest at 'http://www.website.fr/api/login' from origin 'http://localhost:5000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.

When I am in dev it works fine and the API works fine. For the information, the link for my API's I made them in package.json like

"proxy": "http://www.website.fr"

Upvotes: 0

Views: 79

Answers (2)

mbojko
mbojko

Reputation: 14679

That's not a deployment problem - when you deploy your app (I'm assuming at http://www.website.fr), the user won't get CORS error, because it won't be a cross-origin request.

It's a development problem, and for the development process' use it can be solved by disabling CORS check in your browser (there's command line parameters for Chrome, and there's CORS Everywhere plugin for Firefox, among other solutions). Or you can ask the backend guys to (temporarily) enable CORS, if that's a viable solution.

Upvotes: 1

Anh Tuan
Anh Tuan

Reputation: 1143

i think you should install cors lib for your backend app

Upvotes: 0

Related Questions