expressjs cookies aren't showing up in client

33 Views Asked by At

I am using expressjs cookieParser to sign and make http only JWT cookies. I'm not getting any errors but the cookies aren't showing up on my Vite project or when I use Thunderclient to login then test a private route. It says req.cookies are '[Object: null prototype] {}'

              const AccessToken = generateAccessToken({
                username: user.username,
                email: user.email,
                id: user.id,
              });

              const RefreshToken = generateRefreshToken({
                username: user.username,
                email: user.email,
                id: user.id,
              });

              res
                .cookie("access_token", AccessToken, {
                  httpOnly: true,
                  secure: false,
                  sameSite: "none",
                  maxAge: 900000, // 15 min in milliseconds
                })
                .cookie("refresh_token", RefreshToken, {
                  httpOnly: true,
                  secure: false,
                  sameSite: "none",
                  maxAge: 86400000, // 1 day in milliseconds
                })
                .status(200)
                .json({
                  message: "Success login",
                  id: user.id,
                  email: user.email,
                  username: user.username,
                });
0

There are 0 best solutions below