SpringBoot升级2.5.1跨域异常:When allowCredentials is true, allowedOrigins cannot contain the specia
SpringBoot升级2.5.1升级之后启动服务,接口访问出现如下异常。
When allowCredentials is true, allowedOrigins cannot contain the specia
排查之后确认时跨域设置问题。
当
AllowCredentials
为true
,AllowedOrigin
不允许为*
,此时调整为使用AllowedOriginPattern
即可。
更改之前:
corsConfiguration.setAllowCredentials(true);
corsConfiguration.addAllowedOrigin("*");
...
更改之后:
corsConfiguration.setAllowCredentials(true);
corsConfiguration.addAllowedOriginPattern("*");
...
ps.跨域的配置方式可能不一样,但是核心就是这个。