Questions tagged «xmlhttprequest-level2»

7
当http:// localhost是起源时的致命CORS
即使我为服务器(nginx / node.js)设置了适当的标头,我仍然会遇到CORS问题。 我可以在“ Chrome网络”窗格->响应标题中看到: Access-Control-Allow-Origin:http://localhost 这应该可以解决问题。 这是我现在用来测试的代码: var xhr = new XMLHttpRequest(); xhr.onload = function() { console.log('xhr loaded'); }; xhr.open('GET', 'http://stackoverflow.com/'); xhr.send(); 我懂了 XMLHttpRequest无法加载http://stackoverflow.com/。Access-Control-Allow-Origin不允许使用原始http:// localhost。 我怀疑这是客户端脚本而不是服务器配置中的问题...
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.