1
0
mirror of https://github.com/spl0k/supysonic.git synced 2024-12-23 01:16:18 +00:00

Add CORS header on JSON responses only

This commit is contained in:
spl0k 2018-01-27 17:18:30 +01:00
parent b33e8ae6d1
commit aedda4f642
2 changed files with 3 additions and 9 deletions

View File

@ -101,14 +101,6 @@ def get_client_prefs():
request.client = client 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) @app.errorhandler(404)
def not_found(error): def not_found(error):
if not request.path.startswith('/rest/'): if not request.path.startswith('/rest/'):

View File

@ -83,7 +83,9 @@ def value_tostring(value):
return str(value) return str(value)
def make_json_response(response, error = False): 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): def make_jsonp_response(response, callback, error = False):
if not callback: if not callback: