From 2b93404dc0d11114a00427f1ea54a856c88cfef4 Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Sun, 28 Nov 2021 14:23:08 +0100 Subject: [PATCH] [core] Add CORS headers --- flaschengeist/app.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/flaschengeist/app.py b/flaschengeist/app.py index 8d15c11..fbbdf60 100644 --- a/flaschengeist/app.py +++ b/flaschengeist/app.py @@ -108,6 +108,14 @@ def create_app(test_config=None): 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) def handle_exception(e): if isinstance(e, HTTPException):