访问控制来源不允许

我在AngularJS中面对“不允许访问控制源”问题,并基于AngularJS CORS问题我在代码中添加了以下几行:

angular.module('app', [ 'ngRoute', 'appModules.filters', 'appModules.ajaxCallService' ]) .config(['$routeProvider', '$httpProvider', function($routeProvider, $httpProvider) { $httpProvider.defaults.useXDomain = true; delete $httpProvider.defaults.headers.common['X-Requested-With']; $routeProvider.when('/login', {templateUrl: 'views/login.html', controller: 'LoginCtrl'}); }]); 

但是我仍然面临着一个问题:

XMLHttpRequest cannot load http://127.0.0.1:8000/login. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost' is therefore not allowed access.

任何人都可以帮我解决这个问题?

即使在URL中使用本地主机,我得到同样的问题

XMLHttpRequest cannot load http://localhost:8000/login. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost' is therefore not allowed access.

我正在使用AngularJS 1.2.16版和expressJS 0.10.26 nodejs。

我的问题得到解决,我已经添加

  res.setHeader('Access-Control-Allow-Origin', 'http://localhost'); res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS, PUT, PATCH, DELETE'); res.setHeader('Access-Control-Allow-Headers', 'X-Requested-With,content-type'); res.setHeader('Access-Control-Allow-Credentials', true); 

在我的expressJS代码中,同时发送数据到客户端应用程序。