diff --git a/server/src/wled_controller/static/sw.js b/server/src/wled_controller/static/sw.js index 1e8643d..e3e6427 100644 --- a/server/src/wled_controller/static/sw.js +++ b/server/src/wled_controller/static/sw.js @@ -7,10 +7,11 @@ * - Navigation: network-first with offline fallback */ -const CACHE_NAME = 'ledgrab-v1'; +const CACHE_NAME = 'ledgrab-v2'; +// Only pre-cache static assets (no auth required). +// Do NOT pre-cache '/' — it requires API key auth and would cache an error page. const PRECACHE_URLS = [ - '/', '/static/css/base.css', '/static/css/layout.css', '/static/css/components.css', @@ -75,14 +76,17 @@ self.addEventListener('fetch', (event) => { return; } - // Navigation: network-first + // Navigation: network-only (page requires auth, no useful offline fallback) if (event.request.mode === 'navigate') { event.respondWith( fetch(event.request).catch(() => - caches.match('/') || new Response('Offline', { - status: 503, - headers: { 'Content-Type': 'text/plain' }, - }) + new Response( + '
' + + 'Cannot reach the server. Check that it is running and you are on the same network.
' + + '' + + '', + { status: 503, headers: { 'Content-Type': 'text/html' } } + ) ) ); return;