Request Cookies Returns Undefined
I have been stocked into this for quite a while now. Whenever I pass this code
app.get("/", function (req, res) {
const rf_token = "Hello Express Cookies";
res.cookie("refreshtoken", rf_token, {
httpOnly: true,
path: "/api/users/refresh_token",
maxAge: 7 * 24,
});
console.log("refresh_token: ", req.cookies.refreshtoken);
});
Sadly, this is what it returns
refresh_token: undefined
I read through some solutions provided here but it seems not to run for me
app.use(cors());
app.use(morgan("dev"));
app.use(express.json());
app.use(cookieParser());
app.use("/api/users", userRouter);
I initialized cookie-parser before my route.
Kindly check this out. Thanks in anticipation!
from Recent Questions - Stack Overflow https://ift.tt/3tbMMmz
https://ift.tt/eA8V8J
Comments
Post a Comment