forked from ungleich-public/dynamicweb
Disable caching and report the chosen site in dev responses
Adds Cache-Control: no-store and an X-Dev-Site header to the dev site switcher so a browser cannot reuse another site's page or redirect, and the selected site is visible in dev tools.
This commit is contained in:
parent
8874fe4298
commit
4379e9fb89
1 changed files with 5 additions and 1 deletions
|
|
@ -73,9 +73,13 @@ class DevSiteSwitcherMiddleware(object):
|
|||
request.META.pop('HTTP_X_FORWARDED_HOST', None)
|
||||
|
||||
def process_response(self, request, response):
|
||||
site = request.META.get('DEV_SITE_SWITCH', '')
|
||||
# dev only: never let a browser reuse a page or redirect from another
|
||||
# site, and show which site the server picked (see browser dev tools)
|
||||
response['Cache-Control'] = 'no-store'
|
||||
response['X-Dev-Site'] = site or '(default)'
|
||||
if 'site' not in request.GET:
|
||||
return response
|
||||
site = request.META.get('DEV_SITE_SWITCH', '')
|
||||
if site:
|
||||
response.set_cookie(self.COOKIE, site)
|
||||
location = response.get('Location', '')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue