如何通过Google Chrome的内容安全政策允许天气Api?

时间:2016-09-19 03:26:03

标签: json google-chrome google-chrome-extension weather-api

我正在开发类似于Momentum的Google Chrome扩展程序,其中通过API显示天气。在这里,正在使用forecast.io。

由于Chrome中的内容安全政策,我无法显示天气。

这是错误:

  

jquery.min.js:4拒绝加载脚本   ' https://api.forecast.io/forecast/ APIKEY / 位置 ...单位= SI&安培;回调= jQuery31009807237261119963_1474254572792&安培; _ = 1474254572793'因为它违反了以下内容安全策略指令:   " script-src' self' https://ajax.googleapis.com"

我知道这与阻止它的政策有关,但我应该如何解除阻止呢?

我在manifest.json中试过这个:

{
    "name": "Linkage",
    "description": "A new tab page.",
    "version": "0.8",
    "manifest_version": 2,
    "icons": {
        "128": "icon_128.png"
    },
    "chrome_url_overrides": {
        "newtab": "index.html"
    },
    "content_security_policy": "script-src 'self' https://ajax.googleapis.com;  object-src 'self';",
    "permissions": [
        "https://api.forecast.io/forecast/"
    ]
}

所以,我已经尝试将API网站放在其他答案中提到的权限中,但是如错误所示,这不起作用。

那么,我应该如何解除阻止呢?

提前致谢。

0 个答案:

没有答案