Google chrome extension 后台脚本中的Chrome扩展跨源请求被阻止

Google chrome extension 后台脚本中的Chrome扩展跨源请求被阻止,google-chrome-extension,Google Chrome Extension,我尝试从我的后台脚本中获取数据,就像推荐的那样,但它总是被阻止。我错过什么了吗 Background.js: chrome.storage.sync.get(['sigurl'], function(result) { console.log(result.sigurl); fetch(result.sigurl) .then((response) => { return response.text(); })

我尝试从我的后台脚本中获取数据,就像推荐的那样,但它总是被阻止。我错过什么了吗

Background.js:

    chrome.storage.sync.get(['sigurl'], function(result) {
      console.log(result.sigurl);
      fetch(result.sigurl)
      .then((response) => {
        return response.text();
      })
      .then((html) => {
        console.log(html);
        chrome.storage.sync.set({'sig': html}, function() {});
      })
      .catch(function(err) {
            console.log('Failed to fetch page: ', err);
        });
    });

控制台:

Access to fetch at 'http://example.com/test.html' from origin 'chrome-extension://pbflkjmmkpgddamdcihlbggdccjmjmbk' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

使用无cors模式也不起作用

我的问题的解决方案是添加

"permissions": [
    "https://*/"
  ]
到我的manifest.json


感谢wOxxOm为我指明了正确的方向。

我的问题的解决方案是添加

"permissions": [
    "https://*/"
  ]
到我的manifest.json


感谢wOxxOm为我指明了正确的方向。

添加
http://example.com/
to.@wOxxOm后台脚本不应该被CORS阻止吗?@avalanche1,请参阅我在第一条评论中给出的链接。添加
http://example.com/
to.@wOxxOm后台脚本不应该被CORS阻止吗?@avalanche1,请参阅我在第一条评论中给出的链接。我想知道这是否会产生
扩展名can:Read并更改您访问的网站上的所有数据
警告@wOxxOmi刚刚意识到,您应该只在许可证中添加您想要访问的网站,以限制恶意代码,如wOxxOmi给出的链接所示。我想知道这是否会产生
扩展can:读取并更改您访问的网站上的所有数据
警告@wOxxOmi刚刚意识到,你应该只在许可证中添加你想要访问的网站,以限制恶意代码,如WOxxOm给出的链接所示