简体   繁体   中英

Google Chrome Extension error - Access-Control-Allow-Origin

XMLHttpRequest cannot load http://localhost:4567/save . Origin chrome-extension://cbemaelkkmebiohhjgmlclegalijdbbh is not allowed by Access-Control-Allow-Origin.

Even thought I'm getting this error the extension seems to be calling the URL. The message passing from contentscript.js to background.html took me a few minutes to wire up, but seems ok. I'm confused.

Here is my manifest.

{
  "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/*" ]
}

Try changing http://* to http://*/ (and removing the localhost entry).

If you're trying to access a https page, you will need that too.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM