Basically, I have an AJAX request like this:
$.ajax({ url: "http://192.168.0.100/",
success: function(x) { console.log(x); }
});
with the following permissions array defined in manifest.json
of the extension:
"permissions": [
"notifications",
"ta开发者_StackOverflow中文版bs",
"*.*",
"192.168.0.100",
"192.168.0.100/*",
]
A request to 192.168.0.100
fails with the following error:
XMLHttpRequest cannot load http://192.168.0.100/.
Origin chrome-extension://<hash> is not allowed by Access-Control-Allow-Origin.
What I already did is appending this header in index.php
:
Header("Access-Control-Allow-Origin: *");
but to no avail.
What can I do to make AJAX requests to local IPs work in a Chrome extension?
Try using "http://192.168.0.100/*"
instead of "192.168.0.100/*"
. The scheme needs to be specified, see Match Patterns for reference.
精彩评论