I am working on laravel progressive web application . I initiate the service worker in app.js . My service worker file is in ./public directoy . its name is service-worker.js.
but the problem is when i run the app in localhost its showing the folling error in console.
"uncaught (in promise) DOMException: Failed to register a ServiceWorker: The script has an unsupported MIME type ('text/plain')."
So how can i solve this please tell me. in app.js i included below code:
if ('serviceWorker' in navigator)
{
window.addEventListener('load', function() {
navigator.serviceWorker.register('/service-worker.js');
});
}