我知道。
- 在客户端将withCredentials设置为true
// 当发送跨域请求时,携带cookie信息
xhr.withCredentials = true;
- 设置res.header(‘Access-Control-Allow-Credentials’, ‘http://localhost:3000’);
- 设置res.header(‘Access-Control-Allow-Credentials’, true);
// 拦截所有请求
app.use((req, res, next) => {