Google chrome extension 如何在Chrome扩展中创建XMLHttpRequest?

Google chrome extension 如何在Chrome扩展中创建XMLHttpRequest?,google-chrome-extension,content-security-policy,Google Chrome Extension,Content Security Policy,如何在不限制内容安全策略的情况下生成XMLHttpRequest?只是想得到一个运行的概念验证,并且以后可以更好地处理权限。在尝试向发出get请求时,我不断遇到以下两个错误:https:///v1/api?q=value 第一: Refused to connect to 'https://<domain>/v1/api?q=value' because it violates the following Content Security Policy directive:

如何在不限制内容安全策略的情况下生成XMLHttpRequest?只是想得到一个运行的概念验证,并且以后可以更好地处理权限。在尝试向发出get请求时,我不断遇到以下两个错误:https:///v1/api?q=value

第一:

Refused to connect to 'https://<domain>/v1/api?q=value' 
  because it violates the following Content Security Policy directive:
    "connect-src http://localhost:3000 https://localhost:3000".
拒绝连接到'https:///v1/api?q=value' 
因为它违反了以下内容安全策略指令:
“连接srchttp://localhost:3000 https://localhost:3000".
第二:

Error in response to tabs.query: SecurityError: 
  Failed to execute 'open' on 'XMLHttpRequest': 
    Refused to connect to 'https://<domain>/v1/api?q=value' 
     because it violates the document's Content Security Policy.
Error: Failed to execute 'open' on 'XMLHttpRequest': 
  Refused to connect to 'https://<domain>/v1/api?q=value' 
    because it violates the document's Content Security Policy.
响应选项卡时出错。查询:SecurityError: 无法对“XMLHttpRequest”执行“open”: 拒绝连接到'https:///v1/api?q=value' 因为它违反了文档的内容安全策略。 错误:未能对“XMLHttpRequest”执行“open”: 拒绝连接到'https:///v1/api?q=value' 因为它违反了文档的内容安全策略。 我确实在清单文件中添加了以下内容:

"content_security_policy": "default-src 'self' https://<domain>"
“内容安全策略”:“默认src‘self’https://”

有人能帮我配置我的扩展,这样我就可以不受任何限制地发出请求吗?我用它作为基地。谢谢

确保您已经看到了这一点:您需要在后台/事件页面中发出请求。关于stackoverflow有一些/许多例子。另外,使用fetch代替xhr。