0
votes

When I try fetch data from localhost:5000 (my api is at localhost:8080) i have an error:

Fetch API cannot load http://localhost:5000/users/1. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://127.0.0.1:8080' is therefore not allowed access. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

I know that i must add header Access-Control-Allow-Origin: * but i don't know where. I'm using JS+Python (ReactJS and Flask frameworks)

1
In your python/flask routes of the API. If you add the code for that we can help you further.Fabian Schultz
Thanks! "Flask" was key-word :) I find solution here: flask.pocoo.org/snippets/56Krasnal

1 Answers

0
votes

You will have to add in your web server whichever you're using ; provided that you are taking security risk.