I have an express server set up like this:
const express = require("express");
const app = express();
const cors = require("cors");
const cookieParser = require("cookie-parser");
app.use(express.json());
app.use(cors());
app.use(cookieParser());
app.post("/", (req, res) => {
console.log(req.cookies)
res.send();
});
app.listen(5000);
And the output of this is an empty object, but in my client-side (that is making the request), if I log document.cookie
it prints a string with many values. Any idea why the same is not showing up in the server log?
EDIT`: the exact log is [Object: null prototype] {}
This is the request:
const login = async () => {
const resp = await fetch("http://localhost:5000", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({msg: "example"}),
});
};
login();