Hi all,
I'm one of the maintainers of
django-pattern-library, which allows Django templates to be rendered with dummy context provided in static files. These rendered versions of the templates are show in an iframe, which means we have a bit of a niche issue.
On Django >= 3.0, if a user has DEBUG = True in their settings, although
our template rendering view correctly sets the X-Frame-Options header to "SAMEORIGIN" on responses, if the rendering of the template throws an error and the user doesn't also have
X_FRAME_OPTIONS = 'SAMEORIGIN' set in their settings, then the browser will block the debug response from being shown.
The current solution is to instruct users to set X_FRAME_OPTIONS = 'SAMEORIGIN' or looser in their (development) settings, but this seems less than ideal to me.
I was wondering if it would be possible to copy the value of the X-Frame-Options from the view that threw an error to the debug views' responses so that in the case the original response was allowed to be shown in an iframe, the stacktrace could be shown instead without changing the project-wide default of a security heading.
I'd be happy to have a go at this, but from a quick look it's not trivial. Any thoughts about whether this would be desirable or even possible and guidance about how I might start would be very gratefully received!
Cheers,
Ben