How to enable cors
congjinruo opened this issue · comments
Kuai commented
before use flask_graphql:
@app.route('/api/currentUser/')
def currentUser():
jsonStr = '{"name":"XXX","avatar":"XXX","userid":"00000001","notifyCount":12}'
res = flask.Response(jsonStr)
res.headers['Access-Control-Allow-Method'] = 'GET,POST,OPTIONS,DELETE,PUT'
res.headers['Access-Control-Allow-Origin'] = '*'
return res
after user flask_graphql:
app.add_url_rule('/graphql', view_func=GraphQLView.as_view('graphql', schema=schema, graphiql = True, context={'session': db_session}))
And I do not know how to enable CORS
Kuai commented
OK , I find this: Flask-CORS