<分区>
我在 AngularJS 中面临“不允许访问控制来源”的问题,基于 AngularJS CORS Issues我在我的代码中添加了以下几行:
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 中使用 localhost 我也会遇到同样的问题
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 和带有 0.10.26 nodejs 的 expressJS。