feat: add service worker cleanup to remove legacy registrations on startup
All checks were successful
CI - Build and Push / Build and Push Docker Image (push) Successful in 23s
All checks were successful
CI - Build and Push / Build and Push Docker Image (push) Successful in 23s
This commit is contained in:
16
src/main.tsx
16
src/main.tsx
@@ -19,6 +19,22 @@ import AuthCallback from './pages/AuthCallback.tsx'
|
|||||||
import BlogPost from './pages/BlogPost.tsx'
|
import BlogPost from './pages/BlogPost.tsx'
|
||||||
import EditPost from './pages/EditPost.tsx'
|
import EditPost from './pages/EditPost.tsx'
|
||||||
|
|
||||||
|
// Ensure any legacy service workers from previous deployments are removed.
|
||||||
|
if ('serviceWorker' in navigator) {
|
||||||
|
navigator.serviceWorker
|
||||||
|
.getRegistrations()
|
||||||
|
.then((registrations) => {
|
||||||
|
registrations.forEach((registration) => {
|
||||||
|
registration.unregister().catch(() => {
|
||||||
|
// Swallow errors since stale service workers are non-critical.
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
// Ignore lookup errors; the app functions without service workers.
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
createRoot(document.getElementById('root')!).render(
|
createRoot(document.getElementById('root')!).render(
|
||||||
<StrictMode>
|
<StrictMode>
|
||||||
<ThemeProvider>
|
<ThemeProvider>
|
||||||
|
|||||||
Reference in New Issue
Block a user