【问题标题】:Problem with manifest Line 1 Column 1 Syntax Error No resource with given URL found清单第 1 行第 1 列语法错误问题没有找到具有给定 URL 的资源
【发布时间】:2020-08-06 05:21:45
【问题描述】:

在清单为空白的情况下部署 react 应用程序站点后,我遇到了问题。在 localhost 上运行时,它在应用程序下的 Chrome 开发控制台下正常显示。这是我在 index.html 上引用它的行。

<link rel="manifest" href="/manifest.json"/>

这是我的 manifest.json

{
  "short_name": "Test",
  "name": "Test React App",
  "icons": [
    {
      "src": "example-192x192.png",
      "type": "image/png",
      "sizes": "192x192"
    },
    {
      "src": "example-512x512.png",
      "type": "image/png",
      "sizes": "512x512"
    }
  ],
  "start_url": "/",
  "display": "fullscreen",
  "theme_color": "#ffffff",
  "background_color": "#ffffff"
}

我花了很多时间试图理解为什么清单在部署时完全空白,但在本地运行时没有任何错误。从文档看来,它应该可以工作。我错过了什么吗?如果有帮助,我将通过 AWS 进行部署。任何信息都会有所帮助。

此外,我还调整了 index.html 使其看起来像 href="manifest.json"

【问题讨论】:

    标签: reactjs amazon-web-services manifest


    【解决方案1】:

    如果您使用 create-react-app 然后使用一些工具来生成您的 favicon 和 html 元标记,那么请注意不要复制 &lt;link rel="manifest" href="/manifest.json"/&gt;。对我来说,这就是导致错误的原因。

    【讨论】:

      【解决方案2】:

      我需要添加crossorigin="use-credentials" 以消除错误。我的manifest.json 位于公共文件夹中。

      &lt;link rel="manifest" crossorigin="use-credentials" href="%PUBLIC_URL%/manifest.json" /&gt;

      【讨论】:

        猜你喜欢
        • 2020-03-29
        • 2021-03-29
        • 2020-03-22
        • 1970-01-01
        • 2019-09-18
        • 2017-09-04
        • 2021-03-27
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多