FIX: Disable service worker proxying in chrome 97-97.0.4692 (#15638)

https://bugs.chromium.org/p/chromium/issues/detail?id=1286367
This commit is contained in:
David Taylor 2022-01-18 19:41:25 +00:00 committed by GitHub
parent fcc80137ce
commit 2d67315c32
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 2 deletions

View File

@ -13,11 +13,15 @@ var cacheVersion = "1";
var discourseCacheName = "discourse-" + cacheVersion;
var externalCacheName = "external-" + cacheVersion;
// Cache all GET requests, so Discourse can be used while offline
// Chrome 97 shipped with broken samesite cookie handling when proxying requests through service workers
// https://bugs.chromium.org/p/chromium/issues/detail?id=1286367
var chromeVersionMatch = navigator.userAgent.match(/Chrome\/97.0.(\d+)/);
var isBrokenChrome97 = chromeVersionMatch && parseInt(chromeVersionMatch[1]) <= 4692;
// Cache all GET requests, so Discourse can be used while offline
workbox.routing.registerRoute(
function(args) {
return args.url.origin === location.origin && !authUrls.some(u => args.url.pathname.startsWith(u));
return args.url.origin === location.origin && !authUrls.some(u => args.url.pathname.startsWith(u)) && !isBrokenChrome97;
}, // Match all except auth routes
new workbox.strategies.NetworkFirst({ // This will only use the cache when a network request fails
cacheName: discourseCacheName,