谷歌加 CORS 错误
Google plus CORS error
我已经实现了使用 https://developers.google.com/+/web/signin/server-side-flow 的AngularJS应用程序
问题是我的AngularJS在一台服务器上,而Rest Api在另一台服务器上。当我尝试登录时,一切正常,直到我的回调函数调用 rest api。
这是错误:
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://liveboard-dev.locastic.com/api/v1/login. This can be fixed by moving the resource to the same domain or enabling CORS.
服务器没有问题,因为我可以从代码的任何部分调用此方法,除非我直接从 google 发送我在弹出窗口关闭后得到的身份验证响应。
我用于调用 api 的 angularjs 代码是:
$http.post(applicationSettings.authenticationAPIUrl, authResult['code'], {headers: {'Content-Type': 'application/octet-stream; charset=utf-8'}}).success(function (response) {
identityService.setIdentity(response);
deferred.resolve(response);
}).error(function (error) {
deferred.reject(error);
});
在角度侧启用 CORS
var myApp = angular.module('myApp', [
'myAppApiService']);
myApp.config(['$httpProvider', function($httpProvider) {
$httpProvider.defaults.useXDomain = true;
delete $httpProvider.defaults.headers.common['X-Requested-With'];
}
]);
相关文章:
- 与域在同一台计算机上运行的NODEJS服务器的CORS错误
- XMLHttpRequest在$.ajax工作的地方给出了CORS错误
- 在Polymer中使用核心ajax时出现CORS错误
- 在 AngularJS 和 CodeIgniter3 中开机自检数据时出现 CORS 错误
- AngularJS应用程序中的CORS错误
- XDomainRequest (CORS) for XML 导致 IE8 / IE9 中的“访问被拒绝”错误
- Meteor:使用HTTP.get从客户端访问网站(CORS错误)
- Catching'阻止加载混合活动内容'CORS错误
- ajax请求出现CORS错误
- 得到403错误;n.ajaxTransport.k.cors.acrossDomain.send"当使用Nod
- 加载模板时出现AngularJS、Localhost和CORS错误
- 谷歌加 CORS 错误
- CORS预检请求错误无法通过安装npm cors软件包解决
- 同一域上的 CORS 错误
- 使用 elasticsearch.js 时出现 CORS 错误
- CORS 过滤器错误 - 需要帮助来修复相同的错误
- 护照节点.js CORS 错误
- 简单请求中的 Cors 错误:请求标头字段 预检响应中的访问控制-允许-标头不允许授权
- Firefox 和 chrome 的 CORS 错误
- 重定向时出现机架 CORS 错误