Req.cookies cannot be obtained

  node.js, question

It’s a headache not to get req.cookies

clipboard.png

It is strange that app.get(“/”, (req, res)) can get req.cookies

clipboard.png

The app.use section has been checked many times without finding any problems.

clipboard.png

No Cookie found

Only request headers for the initial localhost! …
Strangely, shouldn’t cookie be sent to the backend for every http request?
If not, how should the front end be set?

Update the front-end code

clipboard.png

This is a SPA application, there is no page jump

The problem has been solved.

The reason is that I used global.fetch

The fetch method does not take cookie by default! ! !

The solution is

fetch(“/abc”, {credentials: ‘include’}) ! ! !