Fix SW scope to intercept page navigations for offline support
The SW was served from /static/sw.js with default scope /static/, so it only intercepted static asset requests. Page navigations to /capture, /queue, /browser were not handled by the SW at all — Safari showed its native offline error. Fix: serve SW from /sw.js route with Service-Worker-Allowed: / header and register with scope: /. Now the SW intercepts all navigations and serves the offline fallback page when the network is unavailable. Also remove auth-protected page routes from precache (they would cache the login redirect). Pages are cached via network-first on visit instead. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -65,7 +65,7 @@
|
||||
<script>
|
||||
if ('serviceWorker' in navigator) {
|
||||
window.addEventListener('load', () => {
|
||||
navigator.serviceWorker.register('/static/sw.js')
|
||||
navigator.serviceWorker.register('/sw.js', { scope: '/' })
|
||||
.then((registration) => {
|
||||
console.log('Service Worker registered:', registration.scope);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user