使用'script-src'允许网站不会影响错误

时间:2018-09-18 21:40:46

标签: html content-security-policy

我正在扩展浏览器,但是内容安全策略似乎阻止了我的某些内容。我添加了一个meta标签来允许一个网站:

<meta http-equiv="Content-Security-Policy" content="script-src https://cdnjs.cloudflare.com https://cdn.jsdelivr.net">
  

我仍然收到相同的错误消息,说script-src被阻止了。

Warning that Loading failed for the script with source...

Error that the Content Security Policy settings blocked the resource from loading

如何允许加载资源?

p.s。我的目标是Firefox和Google Chrome。

1 个答案:

答案 0 :(得分:0)

没关系,我需要将代码放入manifest.json文件中,而不是放入<head>文件的html中。它应该看起来像这样:

}
"content_security_policy": "script-src 'self' 'unsafe-eval' https://cdnjs.cloudflare.com https://cdn.jsdelivr.net; object-src 'self'",
}

我能够在another post中找到答案,以帮助我解决这个问题。