I am trying to set a cookie with Node.js and express but when I check in chrome dev tools there is no cookie. I am obviously doing something wrong but not sure what.
In my loginController.js I have
exports.postLogin = async (req, res) => {
const { email, password } = req.body;
const user = await authenticate(email, password);
if (!user) return res.status(403).send("Invalid email or password");
const userData = {
name: user.name,
email: user.email,
type: AUTH_USER_TYPE
};
res.cookie("token", userData, { httpOnly: true, signed: true });
res.json(userData);
};
And in app.js I have:
const cookieParser = require("cookie-parser");
app.use(cookieParser(process.env.COOKIE_SECRET));