mirror of
https://git.bsd.gay/fef/nyastodon.git
synced 2024-12-25 07:23:43 +01:00
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
This commit is contained in:
parent
17c1a62ec8
commit
65d6b253fb
1 changed files with 5 additions and 9 deletions
|
@ -10,7 +10,7 @@ function openWebCache() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function fetchRoot() {
|
function fetchRoot() {
|
||||||
return fetch('/', { credentials: 'include' });
|
return fetch('/', { credentials: 'include', redirect: 'manual' });
|
||||||
}
|
}
|
||||||
|
|
||||||
const firefox = navigator.userAgent.match(/Firefox\/(\d+)/);
|
const firefox = navigator.userAgent.match(/Firefox\/(\d+)/);
|
||||||
|
@ -31,14 +31,10 @@ self.addEventListener('fetch', function(event) {
|
||||||
const asyncResponse = fetchRoot();
|
const asyncResponse = fetchRoot();
|
||||||
const asyncCache = openWebCache();
|
const asyncCache = openWebCache();
|
||||||
|
|
||||||
event.respondWith(asyncResponse.then(response => {
|
event.respondWith(asyncResponse.then(
|
||||||
if (response.ok) {
|
response => asyncCache.then(cache => cache.put('/', response.clone()))
|
||||||
return asyncCache.then(cache => cache.put('/', response.clone()))
|
.then(() => response),
|
||||||
.then(() => response);
|
() => asyncCache.then(cache => cache.match('/'))));
|
||||||
}
|
|
||||||
|
|
||||||
throw null;
|
|
||||||
}).catch(() => asyncCache.then(cache => cache.match('/'))));
|
|
||||||
} else if (url.pathname === '/auth/sign_out') {
|
} else if (url.pathname === '/auth/sign_out') {
|
||||||
const asyncResponse = fetch(event.request);
|
const asyncResponse = fetch(event.request);
|
||||||
const asyncCache = openWebCache();
|
const asyncCache = openWebCache();
|
||||||
|
|
Loading…
Reference in a new issue