素写星辰https://suxiexingchen.github.io/2020/03/14/36/上面这个博客写了很多情况,需要的可以去看看。
记录一下我的情况:
查看springboot版本,如果是2.0以后版本,allowCredentials属性的默认值为false,返回的响应头AccessControlAllowCredentials属性值也为false,如果客户端携带cookie的请求这时是不能跨域访问的,所以需要手动在注解中设置allowCredentials为true
@CrossOrigin(allowCredentials = "true")