![在这里插入图片描述](https://img-blog.csdnimg.cn/3a6a784354194d8abde4a086b26d4e9e.png)
默认值:false。在获取同域资源时设置 withCredentials 没有影响。
true:在跨域请求时,会携带用户凭证
false:在跨域请求时,不会携带用户凭证;返回的 response 里也会忽略 cookie
ajax中的作用
跨域请求时是否在请求中协带cookie。
axios.defaults.withCredentials = true;
注意: 前端设置withCredentials 为true时,后端响应头中Access-Control-Allow-Origin必须指定域名,而不能指定为 *。