Passport.js authenticate issue with two simultaneous sessions : "Cannot set headers after they are sent to the client" #995
Unanswered
xmonvoisin
asked this question in
Help
Replies: 1 comment 1 reply
-
I had a very similar issue. I fixed it by replacing "passport.authenticate(strategy..." with "passport.authenticate('strategyName'...". |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
I have issue with this code when testing using 2 simultaneous users (Playwright tests, using 2 workers) :
passport.authenticate(strategy, {}, { failureRedirect:
/login, state: redirect_url }), (err, user, info) => { if (err || !user) { return next(err || info); } req.logIn(user, err => { if (err) { return next(err); } if (loginpopup) { ... } else { return res.redirect('/'); } }); })(req, res, next);
I am receiving this error:
Error: Cannot set headers after they are sent to the client ...
It seems to come from the "res.redirect('/')"
From various posts on stackoverflow, I kind of understand that the issue come from the fact that I do a redirect inside the "authenticate" callback and that redirect interfer with passport's redirect. But I don't know how to solve this.
Could you please help me understand and fix this issue ?
Thanks you
Beta Was this translation helpful? Give feedback.
All reactions