How can I make a CORS XMLHttpRequest directly to an IP address, not an domain.
For example, i load my web page from example1.org.
I try to make a CORS request to http://example2.org/
, thats working.
A CORS request to http://192.168.1.100
is not working. Why?
The target of the example.org DNS entry is 192.168.1.100. The fiddler2 HTTP sniffer says, that the Browser is not even making an request, to check the CORS HTTP Header sent from the server.
I've tried it with Google Chrome Version 29.0.1510.0 canary and Version 26.0.1410.64 m.
Example code for the CORS request (that code is working. I'm not on a page in the example.org origin.):
var req = new XMLHttpRequest();
req.withCredentials = false;
req.open('GET', 'http://example2.org:8088/GetMyData', true);
req.onreadystatechange = function() {
console.log(req.responseText);
};
req.send();
If you attempt at a connection to what is considered a local IP address browsers may have (or may start to have) restrictions.
Another thing that might be causing problems is if your page is on HTTPS and the IP address is not.
However, without more information it is hard to tell what the problem is here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With