Skip to content
Snippets Groups Projects
Verified Commit 96cb34fd authored by Morgan Bazalgette's avatar Morgan Bazalgette
Browse files

Hopefully fix the homepage being loaded issue

parent b3bf2f93
No related branches found
No related tags found
No related merge requests found
Pipeline #
......@@ -9,13 +9,13 @@ function openWebCache() {
}
function fetchRoot() {
return fetch('/', { credentials: 'include' });
return fetch('/web', { credentials: 'include' });
}
// Cause a new version of a registered Service Worker to replace an existing one
// that is already installed, and replace the currently active worker on open pages.
self.addEventListener('install', function(event) {
event.waitUntil(Promise.all([openWebCache(), fetchRoot()]).then(([cache, root]) => cache.put('/', root)));
event.waitUntil(Promise.all([openWebCache(), fetchRoot()]).then(([cache, root]) => cache.put('/web', root)));
});
self.addEventListener('activate', function(event) {
event.waitUntil(self.clients.claim());
......@@ -23,19 +23,19 @@ self.addEventListener('activate', function(event) {
self.addEventListener('fetch', function(event) {
const url = new URL(event.request.url);
if (url.pathname.startsWith('/web/')) {
if (url.pathname.startsWith('/web')) {
const asyncResponse = fetchRoot();
const asyncCache = openWebCache();
event.respondWith(asyncResponse.then(async response => {
if (response.ok) {
const cache = await asyncCache;
await cache.put('/', response);
await cache.put('/web', response);
return response.clone();
}
throw null;
}).catch(() => asyncCache.then(cache => cache.match('/'))));
}).catch(() => asyncCache.then(cache => cache.match('/web'))));
} else if (url.pathname === '/auth/sign_out') {
const asyncResponse = fetch(event.request);
const asyncCache = openWebCache();
......@@ -43,7 +43,7 @@ self.addEventListener('fetch', function(event) {
event.respondWith(asyncResponse.then(async response => {
if (response.ok || response.type === 'opaqueredirect') {
const cache = await asyncCache;
await cache.delete('/');
await cache.delete('/web');
}
return response;
......
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