2013-11-23 62 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

相關問題