【发布时间】:2016-07-07 00:41:06
【问题描述】:
我想在 iis 的子路由中托管我的 nodejs 服务器应用程序。我想要做的是将我的应用程序托管为 localhost:3000/node/ 而不是 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);
});
但这看起来不像是实现这一目标的正确方法。请引导我走向正确的方向。谢谢。
【问题讨论】:
标签: node.js api routing hosting