Home > front end >  response status code 200 but cors error in react js axios
response status code 200 but cors error in react js axios

Time:09-23

I am trying to hit a open source API from enter image description here enter image description here When I hit the same URL from the postman or directly hit the browser URL bar, I get a response without any error. I also tried using the post method, tried js fetch.

CodePudding user response:

I think the website must allow the request from javascript. Thats a server side thing. You shouldn't be able to send request to the backend without proof that you are the "real" frontend it belongs to. Its a security feature from your browser. If you open this normaly the browser doesn't catch that...

To fix that you could write your own backend which catches the request and sends the content to your frontend and then set the cors there.

CodePudding user response:

Cors must be enabled on server-side. For development purposes you can use react proxy settins but on production server you must correctly setup your server to create proxy for this request

  • Related