谷歌浏览器扩展程序错误 - Access-Control-Allow-Origin

3

XMLHttpRequest无法加载http://localhost:4567/save。源chrome-extension:// cbemaelkkmebiohhjgmlclegalijdbbh不被Access-Control-Allow-Origin允许。

即使我收到这个错误,扩展似乎也在调用URL。从contentscript.js到background.html的消息传递花了我几分钟来连接,但看起来没问题。我感到困惑。

这是我的清单。

{
  "name": "FirstExt",
  "version": "1.0",
  "description": "My First Extension",
  "browser_action": {
    "default_icon": "icon.png",
    "popup": "popup.html"
  },
  "content_scripts": [
  {
    "matches": ["http://*"],
    "js": ["jquery.min.js", "contentscript.js"]
  }
  ],
  "background_page": "background.html",
  "permissions": [ "http://*", 
               "http://localhost:4567/*" ]
}

注意:我目前并没有使用popup.html做任何事情。它是空的。 - BuddyJoe
2个回答

11

尝试将 http://* 更改为 http://*/(并移除 localhost 条目)。

如果您正在尝试访问 https 页面,您也需要更改。


8

"http://*"替换为"<all_urls>"


上传扩展前需要删除这个吗? - Jeremy

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接