0

I'm studying react and I'm developing a little web app using the RIOT Api (League of legends api), and I can't access using fetch or axios and others.. because no access through browser (CORS).

The way I can access to this API is using the action curl, so there is any way to make a curl action using react, or which way is the best to make it?

Thanks.

1 Answers1

1

Are you trying to fetch data from the frontend? You should be able to make a request from your backend application without CORS issues. Your browser won't allow it from the frontend though.

There are fixes but most involve using a proxy: https://cors-anywhere.herokuapp.com/

Josh
  • 61
  • 3
  • Yes, the problem is that I have a search form, so when click on the submit button it execute a function which has the fetch function. That's creating the issue. – Automation interest Mar 08 '17 at 15:39
  • @carlesgrau aside from using public proxy services which are unreliable, you can write some server code that makes the request, and then your client makes a request to *your* server. – Brigand Mar 08 '17 at 15:43
  • As @FakeRainBrigand said, server request is the safest and best way to go. Fairly easy to set up aswell. – Josh Mar 08 '17 at 15:48