| | |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer; |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.Conditional; |
| | | import org.springframework.context.annotation.Configuration; |
| | | import org.springframework.context.annotation.EnableAspectJAutoProxy; |
| | | import org.springframework.web.cors.CorsConfiguration; |
| | |
| | | final UrlBasedCorsConfigurationSource urlBasedCorsConfigurationSource = new UrlBasedCorsConfigurationSource(); |
| | | final CorsConfiguration corsConfiguration = new CorsConfiguration(); |
| | | //是否允许请求带有验证信息 |
| | | // corsConfiguration.setAllowCredentials(true); |
| | | // corsConfiguration.setAllowedOrigins(Arrays.asList("*")); |
| | | // corsConfiguration.setAllowedMethods(Arrays.asList("*")); |
| | | // corsConfiguration.setAllowCredentials(true); |
| | | // corsConfiguration.setMaxAge(168000L); |
| | | |
| | | //是否允许请求带有验证信息 |
| | | corsConfiguration.setAllowCredentials(true); |
| | | // 允许访问的客户端域名 |
| | | corsConfiguration.addAllowedOriginPattern("*"); |
| | |
| | | corsConfiguration.addAllowedHeader("*"); |
| | | // 允许访问的方法名,GET POST等 |
| | | corsConfiguration.addAllowedMethod("*"); |
| | | corsConfiguration.setMaxAge(168000L); |
| | | urlBasedCorsConfigurationSource.registerCorsConfiguration("/**", corsConfiguration); |
| | | return new CorsFilter(urlBasedCorsConfigurationSource); |
| | | } |