当我在浏览器上加载应用程序时,我想向应用程序添加一个基本URL。
我的高速公路配置是:
App.js
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(expressSanitizer());
app.use(express.static(__dirname + '/webapp'));
app.engine('html',require('ejs').renderFile);
app.set('view engine', 'html');
AngularJs路由器配置:
index.js
$urlRouterProvider
.when('','login')
.when('/','login')
.otherwise(function($injector, $location){
var state= $injector.get('$state');
state.go('error', { url: $location.path() }, { location: true });
});
//define states
$stateProvider
.state('/',{
templateUrl: 'public/login.html',
controller: 'login',
authenticated:false
})
.state('login',{
url: '/login',
templateUrl: 'public/login.html',
authenticated:false
// controller: 'login'
// template: '<h1> Routing to login page </h1>'
})
我希望类似于在Apache中部署应用程序时的情况。
当前,当我启动服务器时,url类似于localhost:8080/login
,但我希望它成为localhost:8080/CRM/login
。
发布于 2019-12-06 06:07:24
所以,我想出了解决办法。
我在我的index.html中添加了一个基标记,在我的App.js中的所有api中添加了'/CRM‘
index.html
<base href="/CRM/">
App.js
app.use('/CRM/users',appRoutes);
https://stackoverflow.com/questions/59211632
复制相似问题