In reference to the similar question Error: Can't set headers after they are sent to the client
I was getting a similar error and was able to resolve it by adding
return res.redirect(.....);
next()
Could some one explain how this works? Can't seem to understand why this resolves the issue
Edit:Adding more the question
So i have the following route set up
router.get('/register', userDetail, auth.authorize({
failureRedirect: '/login/failure'
}));
And under my userDetail.js
if(req.securityContext.actor.auth_state !== "LOGGEDIN"){
return res.redirect(unifiedLoginUrl);
//next();
}
The above code results in an error, can'set headers after sent