配置 nginx 以在 Web 应用程序中提供 manifest.json 文件

Axe*_*che 2 nginx manifest progressive-web-apps

在我的网络应用程序中,我在开发控制台中出现此错误:

GET /manifest.json 401 (Unauthorized)
manifest.json:1 Manifest: Line: 1, column: 1, Unexpected token.
login:1 Site cannot be installed: the manifest could not be fetched, is empty, or could not be parsed
Run Code Online (Sandbox Code Playgroud)

如果我直接在浏览器url调用json文件是可以的,但是我的app调用不了这个文件,因为nginx返回401错误:

<link rel="manifest" href="/manifest.json">
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明

我怎样才能在 nginx 中允许这个文件?

Pas*_* R. 14

就我而言,添加 crossorigin 属性后此错误已解决:

<link rel="manifest" href="./manifest.json" crossorigin="use-credentials">
Run Code Online (Sandbox Code Playgroud)

  • 多谢。这应该被接受为答案。 (2认同)