Application 类配置 如下:
@Configuration
publicclassCorsConfig {
privateCorsConfiguration buildConfig() {
CorsConfiguration corsConfiguration = newCorsConfiguration();
corsConfiguration.addAllowedOrigin("*");
corsConfiguration.addAllowedHeader("*");
corsConfiguration.addAllowedMethod("*");
returncorsConfiguration;
}
@Bean
publicCorsFilter corsFilter() {
UrlBasedCorsConfigurationSource source = newUrlBasedCorsConfigurationSource();
source.registerCorsConfiguration("/**", buildConfig());
returnnewCorsFilter(source);
}
}
网友评论