feat: add plugin to unregister existing service workers on client
All checks were successful
Build And Push Image / docker (push) Successful in 2m51s

This commit is contained in:
2025-08-07 13:07:51 +02:00
parent cbaedeb0a8
commit 989c56acbf
2 changed files with 20 additions and 94 deletions

View File

@@ -0,0 +1,19 @@
// Plugin to unregister any existing service workers
export default defineNuxtPlugin(async () => {
if (process.client && 'serviceWorker' in navigator) {
try {
const registrations = await navigator.serviceWorker.getRegistrations();
for (const registration of registrations) {
console.log('🧹 Unregistering service worker:', registration.scope);
await registration.unregister();
}
if (registrations.length > 0) {
console.log('✅ All service workers unregistered');
}
} catch (error) {
console.error('❌ Error unregistering service workers:', error);
}
}
});