Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't make request to API on React-Native app when Debug JS Remotely is enabled

I currently work on a React-Native mobile app.

The requests to the server API using fetch works fine, but when I open the "Debug JS Remotely" with Google Chrome, it creates some kind of localhost server and the calls are made from it, and I get the following error from the server API:

XMLHttpRequest cannot load https://my.server.com/data. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8081' is therefore not allowed access.

It's pretty annoying not to be able to track the requests to the server in debug mode.

Any of you have faced a similar issue and do you have a way around it?

Thanks

like image 756
alexmngn Avatar asked Dec 09 '16 14:12

alexmngn


1 Answers

I actually found a solution: I installed the Chrome extension Allow-Control-Allow-Origin:* https://chrome.google.com/webstore/detail/allow-control-allow-origi/nlfbmbojpeacfghkpbjhddihlkkiljbi?hl=en

like image 183
alexmngn Avatar answered Oct 06 '22 01:10

alexmngn