2013-11-23 112 views
0

Express需要的子应用具有定义的绝对路径。 我不能只用'/'otherAppapp路由匹配所有的东西给它。我可以为子应用程序使用透明路线吗?

var app = express(); 
var otherApp = express(); 

app.get('/', function (req, res) { 
    res.send('HELLO!'); 
}); 

//this works 
otherApp.get('/other', function (req, res) { 
    res.send(req.path); 
}); 

//this doesn't 
otherApp.get('/', function (req, res) { 
    res.send(req.path); 
}); 

app.get('/other*', otherApp); 

如果我想改变路线到otherApp,我必须在子应用程序中更改它。

有没有办法来定义所有的子应用这种透明/相对?

回答

1

尝试app.use('/other/', otherApp);。请注意,这是use,而不是get

相关问题