Angularjs 角度http请求的CORS问题
我正在尝试访问pocket API调用的结果,该调用需要发布到他们的域。然而,当我发布时,我发现了这个问题Angularjs 角度http请求的CORS问题,angularjs,node.js,Angularjs,Node.js,我正在尝试访问pocket API调用的结果,该调用需要发布到他们的域。然而,当我发布时,我发现了这个问题 XMLHttpRequest cannot load https://getpocket.com/v3/get. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'localhost:3000' is therefore not allowed access. The
XMLHttpRequest cannot load https://getpocket.com/v3/get. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'localhost:3000' is therefore not allowed access. The response had HTTP status code 406.
但是,我已经将httpProvider选项配置为这样
$httpProvider.defaults.useXDomain = true;
$httpProvider.defaults.withCredentials = true;
delete $httpProvider.defaults.headers.common["X-Requested-With"];
$httpProvider.defaults.headers.common["Accept"] = "application/json";
$httpProvider.defaults.headers.common["Content-Type"] = "application/json";
我原以为配置会允许请求继续进行,但事实并非如此。我需要一个post请求,所以jsonp不能工作。任何想法都将不胜感激 尝试添加这一行
$httpProvider.defaults.useXDomain = true;
啊,你是偶然使用Chrome的吗?如果是的话,你在其他浏览器上试过了吗?是的,我正在使用chrome,不管怎样,来修复chrome上的问题?在firefox和同样的问题上尝试过。Chrome中有一个已知的bug,这里有一个非常有用的解决方案。但是如果我需要调用api来访问另一个资源,我的应用程序在chrome中应该如何工作呢?就好像它在生产中,它会工作吗?难道不是地方发展?这就是我认为你在寻找的答案