diff --git a/supysonic/api/__init__.py b/supysonic/api/__init__.py index b8573dc..7f11491 100644 --- a/supysonic/api/__init__.py +++ b/supysonic/api/__init__.py @@ -101,14 +101,6 @@ def get_client_prefs(): request.client = client -@app.after_request -def set_headers(response): - if not request.path.startswith('/rest/'): - return response - - response.headers['Access-Control-Allow-Origin'] = '*' - return response - @app.errorhandler(404) def not_found(error): if not request.path.startswith('/rest/'): diff --git a/supysonic/api/formatters.py b/supysonic/api/formatters.py index 391d325..370fddf 100644 --- a/supysonic/api/formatters.py +++ b/supysonic/api/formatters.py @@ -83,7 +83,9 @@ def value_tostring(value): return str(value) def make_json_response(response, error = False): - return jsonify(subsonicify(response, error)) + rv = jsonify(subsonicify(response, error)) + rv.headers.add('Access-Control-Allow-Origin', '*') + return rv def make_jsonp_response(response, callback, error = False): if not callback: