Site cannot be installed: no matching service worker detected

。_饼干妹妹 提交于 2019-12-01 02:22:23

Place the service worker script file at the root of your website and set start_url to /, or place it wherever you want and use the scope property and the Service-Worker-Allowed HTTP header as in my other answer.

The create react app service worker only goes into effect in production, so build it and serve it locally to test that the service worker is working properly.

Install serve npm first, if it isn't already: npm i serve -g

Then...

npm run build

serve -s build

It's also likely that once the service worker registers successully, but something like beforeinstallprompt might not get called. If that's the case, publish the app using a host like firebase, which will serve the site over https, then try the beforeinstallprompt there.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!