20 lines
650 B
TypeScript
20 lines
650 B
TypeScript
// 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);
|
|
}
|
|
}
|
|
});
|