引言
跨域问题的讨论前提: 验证码接口返回的验证码信息和登录接口返回的用户信息存储在session。
如果客户端和服务端交互的时候使用的是 token,通过 Authorization头发送到服务端,并没有使用到 cookie,所以客户端没有必要设置
withCredentials: true
。token和验证码可以存储在redis,来解决跨域问题。
/** 跨域属性 开始**/
xhrFields: {
withCredentials: true//xhrFields: {withCredentials: true},这样配置就可以把 cookie 带过去了,不然我们连 session 都没法维护
},