mirror of
https://github.com/ManInDark/HabitTrove.git
synced 2026-03-08 03:29:49 +01:00
fix: remove service worker
This commit is contained in:
@@ -48,23 +48,6 @@ export default async function RootLayout({
|
|||||||
// set suppressHydrationWarning to true to prevent hydration errors when using ThemeProvider (https://ui.shadcn.com/docs/dark-mode/next)
|
// set suppressHydrationWarning to true to prevent hydration errors when using ThemeProvider (https://ui.shadcn.com/docs/dark-mode/next)
|
||||||
<html lang={locale} suppressHydrationWarning>
|
<html lang={locale} suppressHydrationWarning>
|
||||||
<body className={activeFont.className}>
|
<body className={activeFont.className}>
|
||||||
<script
|
|
||||||
dangerouslySetInnerHTML={{
|
|
||||||
__html: `
|
|
||||||
if ('serviceWorker' in navigator) {
|
|
||||||
window.addEventListener('load', () => {
|
|
||||||
navigator.serviceWorker.register('/sw.js')
|
|
||||||
.then(registration => {
|
|
||||||
console.log('ServiceWorker registration successful');
|
|
||||||
})
|
|
||||||
.catch(err => {
|
|
||||||
console.log('ServiceWorker registration failed: ', err);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
`,
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<JotaiProvider>
|
<JotaiProvider>
|
||||||
<Suspense fallback={<LoadingSpinner />}>
|
<Suspense fallback={<LoadingSpinner />}>
|
||||||
<JotaiHydrate
|
<JotaiHydrate
|
||||||
|
|||||||
@@ -30,24 +30,7 @@ const nextConfig: NextConfig = {
|
|||||||
value: 'strict-origin-when-cross-origin',
|
value: 'strict-origin-when-cross-origin',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
}
|
||||||
{
|
|
||||||
source: '/sw.js',
|
|
||||||
headers: [
|
|
||||||
{
|
|
||||||
key: 'Content-Type',
|
|
||||||
value: 'application/javascript; charset=utf-8',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'Cache-Control',
|
|
||||||
value: 'no-cache, no-store, must-revalidate',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'Content-Security-Policy',
|
|
||||||
value: "default-src 'self'; script-src 'self'",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
22
public/sw.js
22
public/sw.js
@@ -1,22 +0,0 @@
|
|||||||
self.addEventListener('push', function (event) {
|
|
||||||
if (event.data) {
|
|
||||||
const data = event.data.json()
|
|
||||||
const options = {
|
|
||||||
body: data.body,
|
|
||||||
icon: data.icon || '/icon.png',
|
|
||||||
badge: '/badge.png',
|
|
||||||
vibrate: [100, 50, 100],
|
|
||||||
data: {
|
|
||||||
dateOfArrival: Date.now(),
|
|
||||||
primaryKey: '2',
|
|
||||||
},
|
|
||||||
}
|
|
||||||
event.waitUntil(self.registration.showNotification(data.title, options))
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
self.addEventListener('notificationclick', function (event) {
|
|
||||||
console.log('Notification click received.')
|
|
||||||
event.notification.close()
|
|
||||||
event.waitUntil(clients.openWindow('/'))
|
|
||||||
})
|
|
||||||
Reference in New Issue
Block a user