0
我想在几个文件中对我的路由进行细分,通常是客户端路由和api的一些内容。当在不同文件中声明路由器时,不会触发一个路由器
所以我宣布我的应用程序,然后
app.use('/', clientRoutes);
app.use('/api', apiRoutes);
在clientRoutes:
module.exports = function (webapp_client_path){
router.get('/', function (req, res) {
res.sendFile(path.join(webapp_client_path, '/','index.html'));
});
return router;
};
在apiRoutes:
module.exports = function(passport){
router.post('/signup', function(req, res) {
console.log('signup!', req.body);
});
return router;
}
所以问题是,apiRoutes不会被触发,如果我把所有东西放在它工作的同一个cleintRoutes文件中。我试图改变根目录(app.use('/',apiRoutes);并在文件router.post('/ api/signup'...)中,但它没有改变任何东西。
我敢肯定,我失去了一些东西基本在这里,但无法找到它是什么呢。感谢您的帮助!