Skip to content
Snippets Groups Projects
Commit 65d6b253 authored by Akihiko Odaki's avatar Akihiko Odaki Committed by Eugen Rochko
Browse files

Let navigator follow redirect instead that handling redirect in fetch (#7500)

* Let navigator follow redirect instead that handling redirect in fetch

* Do not use cache when fetched resource is to redirect
parent 17c1a62e
No related branches found
No related tags found
No related merge requests found
......@@ -10,7 +10,7 @@ function openWebCache() {
}
function fetchRoot() {
return fetch('/', { credentials: 'include' });
return fetch('/', { credentials: 'include', redirect: 'manual' });
}
const firefox = navigator.userAgent.match(/Firefox\/(\d+)/);
......@@ -31,14 +31,10 @@ self.addEventListener('fetch', function(event) {
const asyncResponse = fetchRoot();
const asyncCache = openWebCache();
event.respondWith(asyncResponse.then(response => {
if (response.ok) {
return asyncCache.then(cache => cache.put('/', response.clone()))
.then(() => response);
}
throw null;
}).catch(() => asyncCache.then(cache => cache.match('/'))));
event.respondWith(asyncResponse.then(
response => asyncCache.then(cache => cache.put('/', response.clone()))
.then(() => response),
() => asyncCache.then(cache => cache.match('/'))));
} else if (url.pathname === '/auth/sign_out') {
const asyncResponse = fetch(event.request);
const asyncCache = openWebCache();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment