A platform for community discussion. Free, open, simple.
FIX: Bypass serviceworker cache for auth routes
David Taylor0e3fa4072fb8
diff --git a/app/assets/javascripts/service-worker.js.erb b/app/assets/javascripts/service-worker.js.erbindex 1d889322894..f2640948171 100644--- a/app/assets/javascripts/service-worker.js.erb+++ b/app/assets/javascripts/service-worker.js.erb@@ -7,11 +7,15 @@ workbox.setConfig({debug: false});+var authUrl = "<%= Discourse.base_path %>/auth/";+var cacheVersion = "1";// Cache all GET requests, so Discourse can be used while offlineworkbox.routing.registerRoute(- new RegExp('.*?'), // Matches all, GET is implicit+ function(args) {+ return !(args.url.origin === location.origin && args.url.pathname.startsWith(authUrl));+ }, // Match all except auth routesnew workbox.strategies.NetworkFirst({ // This will only use the cache when a network request failscacheName: "discourse-" + cacheVersion,plugins: [