diff --git a/src/main.tsx b/src/main.tsx index f4ca2de..1ceb3dc 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -19,6 +19,22 @@ import AuthCallback from './pages/AuthCallback.tsx' import BlogPost from './pages/BlogPost.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(