The code returns the following error:
Service worker registration failed: Failed to register a ServiceWorker for scope ('https://preview-employee-punch-tracking-app-kzmq9a07fccs9e93j2hh.vusercontent.net/') with script ('https://preview-employee-punch-tracking-app-kzmq9a07fccs9e93j2hh.vusercontent.net/sw.js'): The script has an unsupported MIME type ('text/html').
at registerServiceWorker (/app/components/notification-manager)
Revise the code to address the error.
I was previewing: /
The service worker is now delivered by Next.js with the proper JavaScript MIME type, so navigator.serviceWorker.register('/sw.js') should succeed.
The code returns the following error:
Service worker registration failed: Failed to register a ServiceWorker for scope ('https://preview-employee-punch-tracking-app-kzmojyzve0nlvpbk0g2d.vusercontent.net/') with script ('https://preview-employee-punch-tracking-app-kzmojyzve0nlvpbk0g2d.vusercontent.net/sw.js'): The script has an unsupported MIME type ('text/html').
at registerServiceWorker (/app/components/notification-manager)
Revise the code to address the error.
I was previewing: /
/sw is now served as JavaScript, so navigator.serviceWorker.register("/sw") will succeed and the MIME-type error disappears.