【发布时间】:2020-03-22 22:06:13
【问题描述】:
这是托管网址:https://serviceworkerspike.azurewebsites.net/
我正在使用 Vuejs 创建 PWA 作为学校项目,每当我使用 Azure 托管网站时,都会发生这种情况,我在 localhost 上没有问题... Chrome devtools 会这样回应:
/manifest.json:1 Failed to load resource: the server responded with a status of 404 ()
/manifest.json:1 Manifest: Line: 1, column: 1, Syntax error.
manifest.json:1 GET https://serviceworkerspike.azurewebsites.net/manifest.json 404
manifest.json:1 Manifest: Line: 1, column: 1, Syntax error.
我在 index.html 中添加了这个:
<link rel="manifest" href="/manifest.json">
这是我的 manifest.json 文件:
{
"name": "MessageBoardUCN",
"short_name": "MessageBoardUCN",
"theme_color": "#ff095a",
"background_color": "#feaaee",
"display": "standalone",
"start_url": "/index.html",
"icons": [
{
"src": "images/icons/icon-72x72.png",
"sizes": "72x72",
"type": "image/png"
},
{
"src": "images/icons/icon-96x96.png",
"sizes": "96x96",
"type": "image/png"
},
{
"src": "images/icons/icon-128x128.png",
"sizes": "128x128",
"type": "image/png"
},
{
"src": "images/icons/icon-144x144.png",
"sizes": "144x144",
"type": "image/png"
},
{
"src": "images/icons/icon-152x152.png",
"sizes": "152x152",
"type": "image/png"
},
{
"src": "images/icons/icon-192x192.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "images/icons/icon-384x384.png",
"sizes": "384x384",
"type": "image/png"
},
{
"src": "images/icons/icon-512x512.png",
"sizes": "512x512",
"type": "image/png"
}
],
"splash_pages": null
}
我尝试过这样的名称和短名称属性:“messageboarducn”
我还尝试将 starturl 编辑为托管 url:“https://serviceworkerspike.azurewebsites.net/”和“/”
我也尝试过将 manifest.json 文件移动到根目录和 /src 目录中,但其他指南告诉我它应该与 index.html 位于同一文件夹中,并且 /public 是默认的
通常你没有 Vuejs 的 web.config 文件,但我什至尝试添加一个如下所示的文件:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.webServer>
<staticContent>
<remove fileExtension=".json" />
<mimeMap fileExtension=".json" mimeType="application/json" />
<mimeMap fileExtension=".webmanifest" mimeType="application/manifest+json" />
</staticContent>
</system.webServer>
</configuration>
如何改正错误?
【问题讨论】:
-
欢迎来到 Stack Overflow!提问时请阅读为什么不在 SO 上上传代码和/或错误图片Discourage screenshots of code and/or errors。
标签: json azure vue.js azure-web-app-service manifest