Access-Control-Allow-Origin on chrome extension

后端 未结 4 1861
我在风中等你
我在风中等你 2020-12-28 19:36

I\'m making a Chrome extension which pulls data from my own server. It uses about 4 httpRequests at a time, but sometimes I get console error as follows:

XMLHt

4条回答
  •  北荒
    北荒 (楼主)
    2020-12-28 20:12

    You're trying to do cross origin resource sharing (CORS). The bad news is that without a server as a middle man there is no way to do this on a normal web page. The good news is that in a chrome extension you can request permission to access any url's you want. Just put something like this in your manifest.json file.

    Allow connections to your site:

     "permissions": [
        "http://*.radionsm.lv/"
      ],
    

    Allow connections to any site:

     "permissions": [
        "http://*/"
      ],
    

    When the user installs your extension chrome will inform them of the permissions required in a dialogue box prior to the completion of the install.

提交回复
热议问题