feat: session deletion, improved tasting deletion visibility, and PWA login loop fix
This commit is contained in:
28
public/sw.js
28
public/sw.js
@@ -1,6 +1,5 @@
|
||||
const CACHE_NAME = 'whisky-vault-v1';
|
||||
const CACHE_NAME = 'whisky-vault-v2'; // Increment version to force update
|
||||
const ASSETS_TO_CACHE = [
|
||||
'/',
|
||||
'/manifest.json',
|
||||
'/icon-192.png',
|
||||
'/icon-512.png',
|
||||
@@ -27,13 +26,36 @@ self.addEventListener('activate', (event) => {
|
||||
);
|
||||
})
|
||||
);
|
||||
self.clients.claim();
|
||||
});
|
||||
|
||||
self.addEventListener('fetch', (event) => {
|
||||
// Network first, fallback to cache
|
||||
const url = new URL(event.request.url);
|
||||
|
||||
// CRITICAL: Always bypass cache for auth, api, and supabase requests
|
||||
if (
|
||||
url.pathname.includes('/auth/') ||
|
||||
url.pathname.includes('/api/') ||
|
||||
url.hostname.includes('supabase.co')
|
||||
) {
|
||||
return; // Let it fall through to the network
|
||||
}
|
||||
|
||||
// Network first for all other requests, especially navigation
|
||||
event.respondWith(
|
||||
fetch(event.request)
|
||||
.then((response) => {
|
||||
// Optionally cache successful GET requests for assets
|
||||
if (
|
||||
event.request.method === 'GET' &&
|
||||
response.status === 200 &&
|
||||
(url.pathname.startsWith('/_next/static/') || ASSETS_TO_CACHE.includes(url.pathname))
|
||||
) {
|
||||
const responseClone = response.clone();
|
||||
caches.open(CACHE_NAME).then((cache) => {
|
||||
cache.put(event.request, responseClone);
|
||||
});
|
||||
}
|
||||
return response;
|
||||
})
|
||||
.catch(() => {
|
||||
|
||||
Reference in New Issue
Block a user