req.logout();
认证用户就像调用req.logout();
一样简单req.logout();
在重定向之前。 app.route( '/注销') .get((req,res)=> { req.logout(); res.redirect( '/'); });您可能已经注意到我们也没有处理丢失的页面(404),在Node中处理此问题的常用方法是使用以下中间件。继续在所有其他路线之后添加:
app.use((req,res,next)=> { res.status(404) .TYPE( '文本') .send('未找到'); });当您认为自己已经做对时,请提交您的页面。