属性“start_url”被忽略,应该与文档的原点相同

时间:2018-02-10 17:58:05

标签: php json http manifest.json

我在使用跨域清单.Json在这里我的Json文件(位于http://123myblog14.co.nf/manifest.json):

{
  "short_name": "Universal Manual",
  "name": "Universal Manual",
  "theme_color": "#4A90E2",
  "background_color": "#F7F8F9",
  "display": "standalone",
  "icons": [
    {
      "src": "https://1.bp.blogspot.com/-jNpzwSZoHI4/Wn8trSeVxOI/AAAAAAAAAao/SJEDZypr0aw22ekaf54gP_uBc0UMIkevACLcBGAs/s320/48x48.png",
      "type": "image/png",
      "sizes": "48x48"
    },
    {
      "src": "https://1.bp.blogspot.com/-EvJoMC9Ofio/Wn8trZJCPeI/AAAAAAAAAak/aVIfXSwRJp0ccKYpXg52ZKs6tNB2SpNDwCLcBGAs/s320/96x96.png",
      "type": "image/png",
      "sizes": "96x96"
    },
    {
      "src": "https://3.bp.blogspot.com/-Al0F7R0hpjo/Wn8trVIOoEI/AAAAAAAAAag/5ESG8a3skgMGEhS5zVZ-5FKPHA3bWTBxQCLcBGAs/s320/144x144.png",
      "type": "image/png",
      "sizes": "144x144"
    },
    {
      "src": "https://1.bp.blogspot.com/-myt190wt15M/WnnH7The49I/AAAAAAAAAZY/86YIMqtB7U8cZ7wHIhFx-pgSHZVg0V5YQCPcBGAYYCw/s320/192x192.png",
      "type": "image/png",
      "sizes": "192x192"
    }
  ],
  "start_url": "/?utm_source=launcher"
}

但Crome在警告中显示出错误。

property "start_url" ignored,should be same origin as document

我在Https的网站上使用它,但托管它的网站不是https。这是理由吗?

1 个答案:

答案 0 :(得分:0)

如果不存在跨源标头,

chrome会将跨源标头设置为主机名,要解决此问题,您需要从您的网站(123myblog14)发送值为Access-Control-Allow-Origin的{​​{1}}

你可以像这样用php发送标题:

*

或通过.htaccess

 header('Access-Control-Allow-Origin','*');

<强>更新

你可以像manifest一样在manifest.json旁边创建一个php文件

<IfModule mod_headers.c> Header set Access-Control-Allow-Origin "*" </IfModule>

manifest.php

您可以从manifest.php

访问manifest.json