From 965b39a84fc240a24ae1bd7215bb06361b6df98f Mon Sep 17 00:00:00 2001 From: Joar Wandborg Date: Sat, 15 Sep 2012 22:18:49 +0200 Subject: [PATCH] Added CORS headers to API json_response --- mediagoblin/plugins/api/tools.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mediagoblin/plugins/api/tools.py b/mediagoblin/plugins/api/tools.py index e3b15b23..5488e515 100644 --- a/mediagoblin/plugins/api/tools.py +++ b/mediagoblin/plugins/api/tools.py @@ -63,6 +63,11 @@ def json_response(serializable, *args, **kw): ''' response = Response(json.dumps(serializable), *args, **kw) response.headers['Content-Type'] = 'application/json' + cors_headers = { + 'Access-Control-Allow-Origin': '*', + 'Access-Control-Allow-Methods': 'POST, GET, OPTIONS', + 'Access-Control-Allow-Headers': 'Content-Type, X-Requested-With'} + response.headers.update(cors_headers) return response -- 2.25.1