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:
parent
b33e8ae6d1
commit
aedda4f642
@ -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/'):
|
||||||
|
@ -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:
|
||||||
|
Loading…
Reference in New Issue
Block a user