8

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?

Mark Amery
  • 110,735
  • 57
  • 354
  • 402
Justin Dearing
  • 12,753
  • 19
  • 80
  • 146

1 Answers1

5

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.

buck
  • 1,342
  • 18
  • 23