5 ms·
How are these set in werkzeug? Sound like you would be using the werkzeug dev server then... But this works for me: @app.errorhandler(ApplicationError)
by mvolfik 5y ago
How are these set in werkzeug? Sound like you would be using the werkzeug dev server then...
But this works for me:
@app.errorhandler(ApplicationError)
def handle(e):
resp = e.args[0]
resp.headers["Access-Control-Allow-Origin"] = "..."
resp.status_code = 500
return resp
@app.route("/err")
def err():
raise ApplicationError(jsonify({"reason": "test"}))
- rastapasta42 5y agoI'm aware about the ability to overwrite error handler with a custom code, but Werkzeug's handler already supports pretty stack traces and much more, and I would rather not re-invent the wheel from scratch. I was talking about using werkzeug's builtin exception handler but with custom headers - which doesn't appear to be supported.
- mvolfik 5y agothat is not supported. But why would you want to serve that with CORS headers? It's only meant to be displayed in the browser and in dev environment, not production