首页 > 解决方案 > 如何将 PWA start_url 设置为与 manifest.json 文件所在位置不同的位置?

问题描述

如何将start_urlPWA 的 url 设置为与 manifest.json 文件所在位置不同的 url?

所以让我们说start_url应该是:/a/demo/1/index.html

然后manifest.json文件位于/storage/demo/1/manifest.json

我将如何正确设置start_urland scope

例如,如果我这样做:

 "start_url": "./",
 "scope": ".",

然后这将允许您安装 PWA,但是当您加载它时,它会加载一个页面,/storage/demo/1/显示在此服务器上找不到。

我意识到该解决方案也与设置服务人员范围有关。

但这会导致控制台中出现错误,内容如下:

Uncaught (in promise) DOMException: Failed to register a ServiceWorker for scope ...: The path of the provided scope ('/a/demo/1/') is not under the max scope allowed ('/storage/demo/1'). Adjust the scope, move the Service Worker script, or use the Service-Worker-Allowed HTTP header to allow the scope.

标签: progressive-web-apps

解决方案


推荐阅读