Nodejs - 托管到子路由

时间:2016-03-20 14:52:03

标签: node.js api routing hosting

我想在iis的子路径中托管我的nodejs服务器应用程序。我想要做的是托管我的应用程序localhost:3000 / node / not localhost:3000 /。 这可以通过

来实现

更改端点
app.get('/', moduleRoutes.root);
app.post('/auth/signup/', authenticationRoutes.signup);

app.get('/node/', moduleRoutes.root);
app.post('/node/auth/signup/', authenticationRoutes.signup);

但我不希望每次更改托管路径时都更改所有api端点。

另一个是

app.use((req, res, next) => {
    //change request location from here by changing 
    req.url = req.url.replace('localhost:3000/node/', 'localhost:3000') 
    //somthing like that
    authorization.memberinfo(req, res, next);
}); 

但这似乎不是实现这一目标的正确方法。请指引我走向正确的方向。谢谢。

1 个答案:

答案 0 :(得分:0)

您可以在Service安装路由器,只需将所有路由添加到该路由器:

Service
相关问题