Open samuelhwilliams opened 5 months ago
In general this isn't possible. Config cannot be changed after the application starts, because there's no way to ensure that change is propagated to other workers, depending on how the server is being used. The built-in Flask dev server uses threads, so it would work there, but it can also be configured for processes, and most other servers use processes.
Ah, interesting technical constraint, that's fair. I was definitely only thinking of the basic local dev case. It's obviously not the end of the world using the config option :)
I was just poking around the debug toolbar - could it not be achieved using the fldt_active
cookie?
See example I've thrown together here: https://github.com/pallets-eco/flask-debugtoolbar/compare/main...samuelhwilliams:flask-debugtoolbar:toggle-redirect-intercept-from-panel
Some questions around how it would interact (or whether it would replace) the DEBUG_TB_INTERCEPT_REDIRECTS
env var, and I've hardcoded some things that should probably be referenced more cleanly (eg cookie name and value), but functionally that works as I'd like for this feature.
I'd be open to cleaning it up, adding tests and raising a PR if it's something you're open to (provided you can share some thoughts on what to do with the env var).
At the moment, the debug toolbar provides an interstitial page upon redirects by default. This can be configured on/off explicitly with the
DEBUG_TB_INTERCEPT_REDIRECTS
setting.I'd find it really useful if this could be toggled directly from the toolbar on the page. :)