Fixed broken Django error pages due to CSP headers

This commit is contained in:
Raphael Michel
2016-07-29 20:53:51 +02:00
parent 4ab819aeed
commit 99604036c2

View File

@@ -147,6 +147,11 @@ class SecurityMiddleware:
return "; ".join(k + ' ' + v for k, v in h.items())
def process_response(self, request, resp):
if settings.DEBUG and resp.status_code >= 400:
# Don't use CSP on debug error page as it breaks of Django's fancy error
# pages
return resp
resp['X-XSS-Protection'] = '1'
h = {
'default-src': "{static}",