【问题标题】:Manifest: property 'start_url' ignored, should be same origin as document清单:属性“start_url”被忽略,应该与文档同源
【发布时间】:2018-01-13 12:59:15
【问题描述】:

我只是在构建一个静态 HTML 页面,我想让它可以安装。

manifest.json

{
    "name": "YYY",
    "short_name": "YYY",
    "icons": [
        {
            "src": "android-chrome-192x192.png",
            "sizes": "192x192",
            "type": "image/png"
        }
    ],
    "theme_color": "#ffffff",
    "background_color": "#ffffff",
    "display": "standalone",
    "start_url":"index.html"
}

index.html

<head>
    <link rel="apple-touch-icon" sizes="180x180" href="https://xxx.png">
    <link rel="icon" type="imageits-not-the-real-one/png" href="https://xxx.png"
        sizes="32x32">
    <link rel="icon" type="imageits-not-the-real-one/png"  href="https://xxx.png"
        sizes="16x16">
    <link rel="manifest"  href="https://my-manifest-its-not-the-real-one.json">
   ..

项目结构

错误

清单:属性“start_url”被忽略,应该与文档同源。

【问题讨论】:

  • 等等!您是否将其链接为 https://manifest.json
  • 不,当然是假的。
  • 您是否尝试在 URL 中使用 /,例如 /index.html
  • 是的。它没有工作:(
  • 您是在本地服务器上工作还是仅仅使用file:/// 访问您PC 上的HTML 文档?

标签: javascript html json progressive-web-apps manifest.json


【解决方案1】:

派对迟到了,但我的网站只接受启用 HTTPS 的完整 URL

我有这个: http://example.com/

但我不得不使用:https://example.com/

否则我得到了

Manifest: property 'start_url' ignored error, should be same origin as document.

【讨论】:

  • 嗨,我有同样的错误,但我的网址也是 https。但清单链接与原始网址不同。
【解决方案2】:

直到今天,当我在朋友的虚拟主机 (MyDomain.com) 上为他建立一个网站时,我才遇到这个问题。

在这种情况下,问题是通过改变来解决的……

"start_url": "https://[website].com/"

到...

"start_url": "https://www.[website].com/"

【讨论】:

  • "www."从技术上讲,它是一个子域,当涉及到 PWA 时,它被认为是与域本身不同的“来源”。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2013-01-18
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-08-07
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多