I've got a Flask app set up like this
from flask import Flask
from flask.ext.cors import CORS
app = Flask( . . . )
app.debug = True
CORS(app, allow_headers='Content-Type')
CORS works correctly for routes that complete properly. However, if an exception is raised, the debug output is generated without CORS headers. This means I cannot see the debug output in chrome. Can I fix this?
The issue has to do with setting debug mode. You can see the discussion about this in this GitHub issue.
There are two ways you could get around this. The easiest is to set the PROPAGATE_EXCEPTIONS
configuration parameter to False
, but this deprives you of the debug-mode stack trace page:
app.config['PROPAGATE_EXCEPTIONS'] = False
The second would be to write your own exception handler. I haven't tried this myself, but the flask source can give you guidance.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With