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






