Spring Boot 后端配置允许跨域
作者:互联网
Spring Boot 后端配置允许跨域
废话少说直接上代码
@Bean
public CorsFilter corsFilter() {
CorsConfiguration config = new CorsConfiguration();
config.setAllowCredentials(true);
config.addAllowedOrigin("*");
config.addAllowedHeader("*");
config.setMaxAge(18000L);
config.addAllowedMethod("*");
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
source.registerCorsConfiguration("/**", config);
return new CorsFilter(source);
}
标签:跨域,CorsConfiguration,Spring,Boot,source,new,config,UrlBasedCorsConfigurationSour 来源: https://www.cnblogs.com/syer/p/15015570.html