如何使用快速 req 对象获取请求路径
2022-08-30 01:05:29
我使用的是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 是 / 当它应该是 /帐户 ??