Set up your Express application to parse the cookies in the header of the incoming request messages but it will giving error in postman thatCannot read properties of undefined (reading 'user')
<pre>TypeError: Cannot read properties of undefined (reading 'user')
i tried to send request form postman but giving error
app.use(cookieParser("12345-67890-09876-54321"));function auth(req, res, next) { console.log(req.headers); var authHeader = req.headers.authorization; if (!authHeader) { var err = new Error("You are not authenticated!"); res.setHeader("WWW-Authenticate", "Basic"); err.status = 401; next(err); return; } var auth = new Buffer.from(authHeader.split(" ")[1], "base64") .toString() .split(":"); var user = auth[0]; var pass = auth[1]; if (user == "admin" && pass == "password") { if (!req.signedCookies.user) { res.cookie("user", "admin", { signed: true }); } next(); // authorized } else { var err = new Error("You are not authenticated!"); res.setHeader("WWW-Authenticate", "Basic"); err.status = 401; next(err); }}