未检测到匹配的服务工作线程:webapp 在子目录中运行

use*_*671 3 service-worker

当我尝试“添加到主屏幕”时,我在控制台中收到以下错误消息

Site cannot be installed: no matching service worker detected. You may need to reload the page, or check that the service worker for the current page also controls the start URL from the manifest
Run Code Online (Sandbox Code Playgroud)

注册服务工作者确实很顺利,似乎没问题: chrome application-Service Worker

它必须与范围有关,因为我在子域(/webconnect/)中运行我的网站:

清单具有以下范围和 start_url 值:

“范围”:“/webconnect/”

“start_url”:“/webconnect/index.html”

我已经完成了故障排除部分,但这对我没有多大帮助:

Troubleshooting

If after testing you are getting the following error in your console:

No matching service worker detected. You may need to reload the page, or check that the service worker for the current page also controls the start URL from the manifest
Then please make sure that 1. Your service worker is functioning properly and without errors, and 2. Your start_url matches an actual url of your website that loads. Else, you will never get the prompt to show!
Run Code Online (Sandbox Code Playgroud)

我是否缺少将网站添加到主页的特定 trcik?

Ash*_*bry 5

将 Service Worker 脚本文件放置在您网站的根目录 ( ),或者将其放置在您想要的任何位置,并像我的其他答案/webconnect/中那样使用scope属性和HTTP 标头。Service-Worker-Allowed