A platform for community discussion. Free, open, simple.
FIX: Disable service worker proxying in chrome 97-97.0.4692 (#15638)
David Taylor2d67315c320c
diff --git a/app/assets/javascripts/service-worker.js.erb b/app/assets/javascripts/service-worker.js.erbindex 52236616ec3..5f16ce4653e 100644--- a/app/assets/javascripts/service-worker.js.erb+++ b/app/assets/javascripts/service-worker.js.erb@@ -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 offlineworkbox.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 routesnew workbox.strategies.NetworkFirst({ // This will only use the cache when a network request failscacheName: discourseCacheName,