set cookie and redirect in express -
i'm trying set cookie response , redirect user if haven't been verified (inside route)
//add jwt token on successful login res.cookie('jwt', user.token) console.log(user) if(user.security.active === false ){ res.status(401).json({error: 'your account has been deactivated'}) } //if user.security.verified == true if(user.security.verified === false){ res.redirect('/verify'); } if(user.security.approved === false) { res.redirect('/approval') } res.redirect('/')
i error on server error: can't set headers after sent.
does mean can't use redirect when set cookie?
wait sorry, added return before each res , works should
if contribute comment further explain please do.
Comments
Post a Comment