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 2 replies
-
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.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
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