javascript - Deadly CORS when http://localhost is the origin -
i stuck cors problem, though set server (nginx/node.js) appropriate headers.
i can see in chrome network pane -> response headers:
access-control-allow-origin:http://localhost which should trick.
here's code use test:
var xhr = new xmlhttprequest(); xhr.onload = function() { console.log('xhr loaded'); }; xhr.open('get', 'http://stackoverflow.com/'); xhr.send(); i get
xmlhttprequest cannot load http://stackoverflow.com/. origin http://localhost not allowed access-control-allow-origin. i suspect it's problem in client script , not server configuration...
chrome does not support localhost cors requests (an open bug since 2010).
to around can use domain lvh.me (which points @ 127.0.0.1 localhost) or start chrome --disable-web-security flag (assuming you're testing).
Comments
Post a Comment