mirror of
https://gitee.com/pan648540858/wvp-GB28181-pro.git
synced 2026-05-25 14:37:53 +08:00
Merge pull request #1759 from guobi777/master
fix: 在SpringBoot 2.4及以上版本处理跨域时,遇到错误提示:当allowCredentials为true时,allowed…
This commit is contained in:
commit
c059bd08dd
@ -148,8 +148,10 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
|
|||||||
corsConfiguration.setAllowCredentials(true);
|
corsConfiguration.setAllowCredentials(true);
|
||||||
corsConfiguration.setAllowedOrigins(userSetting.getAllowedOrigins());
|
corsConfiguration.setAllowedOrigins(userSetting.getAllowedOrigins());
|
||||||
}else {
|
}else {
|
||||||
corsConfiguration.setAllowCredentials(false);
|
// 在SpringBoot 2.4及以上版本处理跨域时,遇到错误提示:当allowCredentials为true时,allowedOrigins不能包含特殊值"*"。
|
||||||
corsConfiguration.setAllowedOrigins(Collections.singletonList(CorsConfiguration.ALL));
|
// 解决方法是明确指定allowedOrigins或使用allowedOriginPatterns。
|
||||||
|
corsConfiguration.setAllowCredentials(true);
|
||||||
|
corsConfiguration.addAllowedOriginPattern(CorsConfiguration.ALL); // 默认全部允许所有跨域
|
||||||
}
|
}
|
||||||
|
|
||||||
corsConfiguration.setExposedHeaders(Arrays.asList(JwtUtils.getHeader()));
|
corsConfiguration.setExposedHeaders(Arrays.asList(JwtUtils.getHeader()));
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user