首页 > 解决方案 > 将外部 api 与 Web 扩展清单 v3 一起使用

问题描述

我正在创建一个网络扩展,我需要在其中使用 google recaptcha。但是当我尝试导入库时出现错误

Refused to load the script 'https://www.google.com/recaptcha/api.js?onload=onloadcallback&render=explicit' because it violates the following Content Security Policy directive: "script-src 'self'". Note that 'script-src-elem' was not explicitly set, so 'script-src' is used as a fallback.

我试图将我的脚本 src 设置为授权对https://www.google.com的请求

"content_security_policy": {
    "extension_pages": "script-src 'self' 'https://www.google.com'; object-src 'self'"
},

但我有一个错误

'content_security_policy.extension_pages': Insecure CSP value "'https://www.google.com'" in directive 'script-src'.

仍然可以将外部脚本与 manifest v3 一起使用,如果可以,我应该怎么做?

标签: google-chrome-extensionrecaptchamanifest.json

解决方案


推荐阅读