Firefox permission to URL doesn't work in browser extension

爷,独闯天下 提交于 2019-12-11 06:08:32

问题


I created Chrome extension and it works as I expected. Actually, it periodically sends http request to my server. But when I tried to run it in Firefox, I've got such an error:

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at <my_server_ip>:8080/. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).

My application listens for incoming requests at server_ip:8080
For making requests to my server from chrome extension, I add such entry to manifest.json:

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

Suddenly, it doesn't work in Firefox and I can't understand why. I tried a workaround (found in this article):

  "permissions": [
    "<all_urls>"
  ],

And the problem with CORS disappeared. But I want to give permissions only to my resourse - server_ip:8080

How I need to put a rule in permissions entry to make extension work in Firefox?


回答1:


To elaborate on wOxxOm's comment you only need this for your URL permission

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


来源:https://stackoverflow.com/questions/41850733/firefox-permission-to-url-doesnt-work-in-browser-extension

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!