我不知道这是否可能,但我想在我的私有附加组件的内容脚本中向本地服务发送一个POST请求。
我尝试使用XMLHttpRequest
发送请求,但由于跨域限制导致发送失败:
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://127.0.0.1:8089/... (Reason: CORS `Access-Control-Allow-Origin' missing).
我在here上读到,我可以指定额外的匹配模式,以允许在内容脚本中进行跨域访问,但在将"http://127.0.0.1:8089/*"
添加到manifest.json
中的permissions
之后,该限制仍然有效。
有没有可能突破跨域限制?如果是这样的话,是怎么做的?
发布于 2018-01-24 21:58:14
根据wOxxOm's comment under this question的规定,端口号不应出现在匹配模式中。
我将manifest.json
中的模式更改为http://127.0.0.1/*
,请求可以成功发送。
https://stackoverflow.com/questions/48415176
复制相似问题