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

问题描述 投票:0回答:1

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

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

我仍然收到相同的错误消息,说脚本src被阻止。

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

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

如何允许加载我的资源?

附:我的目标是Firefox和Google Chrome。

html content-security-policy
1个回答
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找到答案来帮助我。

© www.soinside.com 2019 - 2024. All rights reserved.