简体   繁体   English

AngularJS CORS Access-Control-Allow-Origin错误

[英]AngularJS CORS Access-Control-Allow-Origin errors

I try to access a different domain site that way: http://jsfiddle.net/carolineBda/2uZnP/ 我尝试以这种方式访问​​其他域站点: http : //jsfiddle.net/carolineBda/2uZnP/

I always get (error visible in the console): 我总是得到(错误在控制台中可见):

XMLHttpRequest cannot load http://www.google.fr. 
No 'Access-Control-Allow-Origin' header is present on the requested resource. 
Origin 'http://fiddle.jshell.net' is therefore not allowed access.

I've configured the httpProvider like that: 我已经像这样配置了httpProvider:

app.config(['$httpProvider',function ($httpProvider) {
    $httpProvider.defaults.useXDomain = true;
    delete $httpProvider.defaults.headers.common['X-Requested-With'];
}]);

Any ideas what I'm missing? 有什么想法我想念的吗? Thanks for your help. 谢谢你的帮助。

The service you are requesting is not allowing CORS (no Access-Control are sent as part of the response). 您请求的服务不允许CORS(响应中没有发送Access-Control)。 So the web browser is not allowing it. 因此,网络浏览器不允许这样做。 This is the expected behavior and not an Angular issue. 这是预期的行为,而不是Angular问题。

Also check this 也检查一下

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM