Skip to content

Commit

Permalink
is-ajax check: only check Sec-Fetch-Mode in proxy mode, only treat 'c…
Browse files Browse the repository at this point in the history
…ors' as ajax, fixes change in #563
  • Loading branch information
ikreymer committed Jun 8, 2020
1 parent 3c53c27 commit 135aba9
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions pywb/apps/rewriterapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -837,10 +837,15 @@ def is_ajax(self, environ):
if value and value.lower() == 'xmlhttprequest':
return True

# if Chrome Sec-Fetch-Mode is set and is not 'navigate', then this is likely

# additional checks for proxy mode only
if not ('wsgiprox.proxy_host' in environ):
return False

# if Chrome Sec-Fetch-Mode is set and is set to 'cors', then
# a fetch / ajax request
sec_fetch_mode = environ.get('HTTP_SEC_FETCH_MODE')
if sec_fetch_mode and sec_fetch_mode != 'navigate':
if sec_fetch_mode and sec_fetch_mode == 'cors':
return True

return False
Expand Down

0 comments on commit 135aba9

Please sign in to comment.