I'm trying to return custom headers like this:
@app.route("/generate", methods=['POST'])
def generate():
# data is generated here
resp = Response(jsonify(data))
resp.headers['Access-Control-Allow-Origin'] = '*'
resp.headers['Access-Control-Allow-Credentials'] = True
return resp
But they don't seem to be present in the output.
Changing status code to 201 as mentioned here didn't help either (I did this by adding status=201
to Responce
construction).
Any bit of help would be appreciated.
EDIT 1:
Added a bit to a code.
Solutions described here didn't work for me either. Tried both Response
and make_response
, added @app.after_request
as suggested - no effect.
The only headers present are:
'Content-Type': 'application/json',
'Content-Length': '113',
'Server': 'Werkzeug/1.0.1 Python/3.7.7',
'Date': 'Fri, 08 May 2020 17:05:38 GMT'