mirror of
https://github.com/discourse/discourse.git
synced 2024-11-27 18:13:40 +08:00
FIX: Bypass serviceworker cache for auth routes
This avoids samesite cookie-related issues in iOS PWAs during the authentication flow
This commit is contained in:
parent
5112648796
commit
0e3fa4072f
|
@ -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 offline
|
||||
workbox.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 routes
|
||||
new workbox.strategies.NetworkFirst({ // This will only use the cache when a network request fails
|
||||
cacheName: "discourse-" + cacheVersion,
|
||||
plugins: [
|
||||
|
|
Loading…
Reference in New Issue
Block a user