In my app.js I do this
app.use(function(req, res, next){
if(!req.user){
res.redirect('/login_');
}
next();
})
I don't see anything wrong and in route/index.js I do
router.get('/login_', function(req, res) {
res.render('login', { user : req.user });
});
But I got error of throw new Error('Can\'t set headers after they are sent.');
I know this is caused by the request is not ended but what's wrong with my code above? clueless with this error.
full code of route/index.js http://pastebin.com/kT2QfnjL