cookie-parser icon indicating copy to clipboard operation
cookie-parser copied to clipboard

req.cookies is showing null

Open pargaimanish opened this issue 8 months ago • 0 comments

working on node.js project where creating login and using cookies to store user. but for user validation to get current user. the token validation middleware is giving [Object: null prototype] {}

middle ware:

const vailedToken = asyncHandler(async(req, res, next)=>{
    const token = req.cookies.accessToken;


    console.log(token); 
---stuff----
  } );





});

module.exports = vailedToken;

and when i am testing as get route in app.js. the its showing the req.cookies with accessToken

app.get("/test", (req, res) => {
  console.log("Cookies:", req.cookies);
  res.json(req.cookies);
});

pargaimanish avatar May 03 '25 16:05 pargaimanish