diff --git a/apps/web/public/sw.js b/apps/web/public/sw.js new file mode 100644 index 0000000..ba6afec --- /dev/null +++ b/apps/web/public/sw.js @@ -0,0 +1,23 @@ +// Self-destructing service worker. +// +// buildmymcpserver.com previously ran on GoDaddy Airo, which installed a +// Workbox service worker that pre-cached GoDaddy's pages. That worker keeps +// serving stale GoDaddy content in browsers that visited the parked domain. +// Our app does not use a service worker — this file exists only so that when +// such a browser checks sw.js for an update it receives this script, which +// wipes the caches and unregisters itself. +self.addEventListener('install', () => self.skipWaiting()); + +self.addEventListener('activate', (event) => { + event.waitUntil( + (async () => { + const keys = await caches.keys(); + await Promise.all(keys.map((k) => caches.delete(k))); + await self.registration.unregister(); + const clients = await self.clients.matchAll({ type: 'window' }); + for (const client of clients) { + client.navigate(client.url); + } + })(), + ); +});