nginx 配置
server {
listen 80;
server_name 114.119.5.178 ;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root /root/java/iBase4J-UI;
index index.html index.htm;
if ( -f $request_filename){
root /root/java/iBase4J-UI;
break;
}
if ( !-e $request_uri){
# proxy_pass http://114.119.5.178:8080;
rewrite ^ http://$server_name:8080/iBase4J-Web$request_uri? permanent;
}
}
}
angularJS代码
angular.module('app')
.controller('loginController',[ '$rootScope', '$scope', '$http', '$state', function($rootScope, $scope, $http, $state) {
$scope.user = {};
$scope.login = function () {
$.ajax({
url : '/login',
data: $scope.user
}).then(function(result) {
if (result.httpCode == 200) {
$state.go('main.sys.user.list');
} else {
$scope.msg = result.msg;
$rootScope.$apply();
}
});
}
} ]);
截图
nginx
angualrJS
你说是同一个服务器,但是是同一个域名吗?
假如 www.baidu.com 和 yun.baidu.com 都是指向 172.27.35.99的服务器,但是这是算跨域!