Closed IRediTOTO closed 4 years ago
This pull request is being automatically deployed with Vercel (learn more). To see the status of your deployment, click below or on the icon next to each commit.
Hmm, i found error. Session id change every request :| finding the way to fix it.
I'm not sure that I'm following, but here is my guess.
In pages/api/user/facebook/index.js
, you need to import passport
from lib/passport.js
, not the passport
module itself.
@hoangvvo I tried, all passport is ok. problem come from
res.writeHead(301, { this should be 302
Location: process.env.WEB_URI + "/account",
});
res.end();
If I just req.send("ok")
it will work
Sorry for the late reply. I'm not sure why 302 would make a difference.
@hoangvvo Hi, is use this, and it work
res.setHeader("Location", process.env.WEB_URI + "/user");
res.statusCode=302
res.end();
Look like res.writeHead destroy something.
I understood. It seems like next-session
could not write the Cookie
header because writeHead
had sent out the headers before it got to do so.
https://nodejs.org/api/http.html#http_response_writehead_statuscode_statusmessage_headers
Closing. If there is still a problem, feel free to reopen.
I am trying to implement Facebook login, it's work pretty fine. User can login with FB, server got profile with user's email > then create or authenticate user,... But something wrong in api/user/facebook/callback it's didn't make user session login. And that make user got kick out of profile page. Sometimes it work (on localhost), sometime can't login.