登录代码(前端)
const res = await axios.post(config.url, {
email,
password
}, {
withCredentials: true
})
后端代码
(使用 cookie 解析器)
// cookie response
res.cookie("auth-token", token);
// Express cors middleware
app.use(cors({
credentials: true
}));
浏览器给我们的错误是
The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'.
尝试切换配置,无论如何都不起作用。