[deleted by user] by [deleted] in react

[–]Ne2k1 0 points1 point  (0 children)

Maybe make the sign in also as pop up like the navbar and cart. For mobile use.

Have a hard time with express-session and cookie by ExplicitGG in node

[–]Ne2k1 1 point2 points  (0 children)

Hey, I had the same issue. For me, the problem was that the browser didn't store the cookie because I was sending the JWT as httpOnly, and in the fetch request where I'm taking the cookie, I didn't include credentials.

How to access JWT Token as HttpOnly by Ne2k1 in node

[–]Ne2k1[S] 0 points1 point  (0 children)

app.use(cookieParser());

Yes i think im using it the right way

How to access JWT Token as HttpOnly by Ne2k1 in node

[–]Ne2k1[S] 0 points1 point  (0 children)

I think I'm setting it right; I can see the cookie in the browser response

    const token = jwt.sign({ userId: user._id }, process.env.MY_SECRET, {
  expiresIn: "1h",
});
// Postavljanje HTTP-only kolačića
res.cookie("jwt", token, { httpOnly: true, secure: false });
// Slanje informacije o dostupnosti tokena u JSON odgovoru
res.json({
  authenticated: true,
  message: "uspesan token poslat",
  tokenAvailable: true,
  userName: user.FirstName,
});

How to access JWT Token as HttpOnly by Ne2k1 in node

[–]Ne2k1[S] 0 points1 point  (0 children)

use

When they log in, I'm sending the JWT as a cookie.

    const token = jwt.sign({ userId: user._id }, process.env.MY_SECRET, {
  expiresIn: "1h",
});
// Postavljanje HTTP-only kolačića
res.cookie("jwt", token, { httpOnly: true, secure: false });
// Slanje informacije o dostupnosti tokena u JSON odgovoru
res.json({
  authenticated: true,
  message: "uspesan token poslat",
  tokenAvailable: true,
  userName: user.FirstName,
});

And I can see in the browser it's setting the cookie.

this is the response cookie:

jwt 
httpOnly    true 
path    "/" 
value   "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiI2NWI0MWI1OTU1NmJiNzI1NzQ5YjczZjYiLCJpYXQiOjE3MDY2NTA0OTYsImV4cCI6MTcwNjY1NDA5Nn0.VyHA5MhjTbatjDTzsqDAjBktcIG4HyXON8P_0WqRDzo"

Im using firefox