在Axios的请求配置中设置withCredentials为true
withCredentials
true
示例代码:
axios.get('/api/data', { withCredentials: true }).then(response => { // 处理服务器的响应数据 }).catch(error => { // 处理请求错误 })
在上述代码中,设置withCredentials为true可以让Axios在发送请求时携带上httpOnly cookie,从而解决该问题。
上一篇:axios未覆盖默认的content-type头部
下一篇:Axios未能发送适当的错误响应[React]