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:
parent
fcc80137ce
commit
2d67315c32
|
@ -13,11 +13,15 @@ var cacheVersion = "1";
|
||||||
var discourseCacheName = "discourse-" + cacheVersion;
|
var discourseCacheName = "discourse-" + cacheVersion;
|
||||||
var externalCacheName = "external-" + 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(
|
workbox.routing.registerRoute(
|
||||||
function(args) {
|
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
|
}, // Match all except auth routes
|
||||||
new workbox.strategies.NetworkFirst({ // This will only use the cache when a network request fails
|
new workbox.strategies.NetworkFirst({ // This will only use the cache when a network request fails
|
||||||
cacheName: discourseCacheName,
|
cacheName: discourseCacheName,
|
||||||
|
|
Loading…
Reference in New Issue