@Configuration public class CorsConfig { private CorsConfiguration bulidConfig(){ CorsConfiguration corsConfiguration = new CorsConfiguration(); corsConfiguration.addAllowedHeader("*"); corsConfiguration.addAllowedOrigin("*"); corsConfiguration.addAllowedMethod("*"); corsConfiguration.setMaxAge(3600L); corsConfiguration.setAllowCredentials(true); return corsConfiguration; } @Bean public CorsFilter corsFilter(){ UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); CorsConfiguration corsConfiguration = bulidConfig(); corsConfiguration.addExposedHeader("jti"); source.registerCorsConfiguration("/**",corsConfiguration); return new CorsFilter(source); } }
springboot跨域请求解决header问题
最新推荐文章于 2024-07-05 18:39:33 发布