Chrome not allowing Ajax request to permitted doma

2019-09-02 10:11发布

问题:

I'm creating my first Chrome extension, a relatively simple one with some ajax calls.

My manifest is pretty simple:

{
    "name": "Read It Now",
    "version": "0.12",
    "description": "Read it now.",
    "permissions": [
                    "https://readitlaterlist.com"
                   ],
  "app": {
      "launch": {
          "local_path": "index.html"
      }
  }
}

I'm then using jQuery to fetch some simple data from a URL like:

https://readitlaterlist.com/v2/get?state=unread&count=10&apikey=xxx&username=yyy&password=zzz

However, Chrome still rejects it:

XMLHttpRequest cannot load https://readitlaterlist.com/v2/get?state=unread&count=10&apikey=xxx&username=yyy&password=zzz. Origin chrome-extension://cdfeahailioembamnjnikbiemengfgpp is not allowed by Access-Control-Allow-Origin.

回答1:

You have to include the path in your URL match pattern. "https://readitlaterlist.com/*" should fix your problem.