我正在使用express + node.js,有一个req对象,在浏览器中发出的请求是/account,但当我记录req.path时,我得到的是'/'而不是'/account'。
//auth required or redirect
app.use('/account', function(req, res, next) {
console.log(req.path);
if ( !req.session.user ) {
res.redirect('/login?ref='+req.path);
} else {
next();
}
});
req.path是/,但应该是/account吗?
req.route
未定义。我正在使用express 3.4.4。什么原因会导致路由未定义? - davidpfahler