I have created API using Flask in Python. Now I am trying to create front end, where I want to call API. I set CORS according Flask-Cors documentation, unfortunately it doesn't work.
from flask_cors import CORS
CORS(app)
I got this error CORS error - Safari
I have found some similar topics, where was some solution. I have tried, but neither of them work for me. E.g.
CORS(app, origins=['http://localhost:4200'])
app.config['CORS_HEADERS'] = 'Content-Type'
I have also tried cross_origin decorator, but it doesn't work as well.
@app.route("/login", methods = ["POST"])
@cross_origin(origin='*')
def login():
credentials = request.get_json()
....
Could someone help me, how to solve this problem?
CodePudding user response:
Make sure the URL you are trying to access begins with 'http://'
or 'https://'
according to your web server's configuration