1. The cookie can be set successfully, but why can’t it be obtained? req.cookies has always been {}
The relevant parsing cookie npm package has been referenced
and the setting is successful.
But when I refresh to get req.cookies, it is always {}. This is why. . . ? ? ?
(1). Debugging is local environment debugging
Are the client and server cross-domain?
Cross-domain requests will not automatically bring cookies. You will know by looking at the Request Headers of the network.
If you want to bring cookies with cross-domain requests, ajax must set withCredentials: true