Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Enable CORS in React app

I am setting up a React application that extracts from a public API. When I am testing the API in Postman, it works without problems. But if I use fetch() in my React app, I get a CORS error.

As far as I have understood, my client request should be allowed on the server using headers. But I don't own the server hosting the API, so I cannot do anything on the server. The API is configured to be used by third party applications using an access code, so I am a bit confused why it's not allowed to extract from the API in React.

What are my options?

like image 446
mortensen Avatar asked Jun 25 '26 19:06

mortensen


1 Answers

if you don't have server access then you can bypass it

  • CORS Anywhere: https://cors-anywhere.herokuapp.com/
  • All Origins: http://allorigins.me/
  • Any origin: http://anyorigin.com/
like image 62
ehmad11 Avatar answered Jun 27 '26 09:06

ehmad11



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!