[core] Add CORS headers

This commit is contained in:
Ferdinand Thiessen 2021-11-28 14:23:08 +01:00
parent a479d0c0ee
commit 2b93404dc0
1 changed files with 8 additions and 0 deletions

View File

@ -108,6 +108,14 @@ def create_app(test_config=None):
return jsonify({"plugins": app.config["FG_PLUGINS"], "version": version}) return jsonify({"plugins": app.config["FG_PLUGINS"], "version": version})
@app.after_request
def after_request(response):
header = response.headers
header['Access-Control-Allow-Origin'] = '*'
header["Access-Control-Allow-Methods"] = "GET,HEAD,OPTIONS,POST,PUT"
header["Access-Control-Allow-Headers"] = "Origin, X-Requested-With, Content-Type, Accept, Authorization"
return response
@app.errorhandler(Exception) @app.errorhandler(Exception)
def handle_exception(e): def handle_exception(e):
if isinstance(e, HTTPException): if isinstance(e, HTTPException):