How to send POST data to flask using Reactjs fetch
It is a problem of Cross Origin Resource Sharing. In you case you are trying to access the API endpoint from the different URL as the API is being served on itself. By the way, 127.0.0.1:3000 and 127.0.0.1:5000 considered as two different URLs, therefore causing the error that you are referring to. So, to fix this you need to perform the following steps:
Install Flask-CORS:
pip install flask-cors
Include this code in your Flask application (probably __init__.py):
from flask_cors import CORSCORS(app)
That's it!