Unable to install site: the corresponding service employee was not found

Hey, I'm trying to program my first pwa and got the following problem:

when I run my web application, I get the following error:

Unable to install site: the corresponding service employee was not found. You may need to reload the page or verify that the production service for the current page also controls the start URL from the manifest

I think my explicit url is right because of this link

manifest.json

"start_url": ".", "display": "standalone", "orientation": "portrait", "theme_color": "#29BDBB", "background_color": "#29BDBB" 

and I will register my sw like this:

 if ('serviceWorker' in navigator) { navigator.serviceWorker.register('./sw.js').then(function(reg) { console.log('Successfully registered service worker', reg); }).catch(function(err) { console.warn('Error whilst registering service worker', err); }); } 

I got my sw from here

So, I am trying to create a simple web application in which I can host firebase .

What is the problem? Thank you for your help.

+14
source share
2 answers

Put the script service file in the root directory of your site and set start_url to / or put it where you want and use the scope property and the HTTP header Service-Worker-Allowed , as in my other answer .

+12
source

The Responsive Application Creation Service employee only takes effect in the production environment, so collect it and service it locally to see if the service worker is working properly.

Install serve npm first, if it's not npm serve -g yet npm serve -g : npm serve -g

Then...

npm run build

serve -s build

It is also likely that one day the beforeinstallprompt service worker beforeinstallprompt register, but something like beforeinstallprompt may not be called. If so, publish the application using a host such as firebase, which will serve the site via https , and then try beforeinstallprompt before beforeinstallprompt .

+1
source

Source: https://habr.com/ru/post/1270631/


All Articles