From: Joar Wandborg Date: Sat, 15 Sep 2012 20:18:49 +0000 (+0200) Subject: Added CORS headers to API json_response X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=965b39a84fc240a24ae1bd7215bb06361b6df98f;p=mediagoblin.git Added CORS headers to API json_response --- 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