内容安全策略:无法在Chrome扩展中加载Google API React
我正在使用React和实现Google Ingup创建Chrome扩展名
,因此我
<script src="https://apis.google.com/js/api.js"></script>
现在在index.html中
添加了Chrome 。当我构建代码并部署时,Chrome显示错误,说
Refused to load the script 'https://apis.google.com/js/api.js' because it violates the following Content Security Policy directive: "script-src 'self' 'unsafe-eval' https://cdn.jsdelivr.net". Note that 'script-src-elem' was not explicitly set, so 'script-src' is used as a fallback.
我正在使用明确版本3 文件。
所以我添加了
"content_security_policy": {
"extension_pages": "script-src 'self' https://apis.google.com; object-src 'self'"
}
,但是现在这表明
content_security_policy.extension_pages': Insecure CSP value "https://apis.google.com" in directive 'script-src'.
Could not load manifest.
我该如何解决?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

我通过在响应中添加标头来管理CSP,例如 -
我不确定明确版本3文件是什么意思
您可以尝试将此行添加到您的代码(您的要求) -
I managed CSP with my nginx settings by adding headers to my response, such as -
I'm not sure what do you mean by manifest version 3 file
Can you try adding this line to your code (your requirement) -