1@Override
2 public void configure(HttpSecurity http) throws Exception {
3 http.cors().configurationSource(request -> new CorsConfiguration().applyPermitDefaultValues())
4 // ...
5 }
6
7
8 @Bean
9 public WebMvcConfigurer corsConfigurer() {
10 return new WebMvcConfigurer() {
11 @Override
12 public void addCorsMappings(CorsRegistry registry) {
13 registry.addMapping("/**")
14 .allowedOrigins("*")
15 .allowedMethods("GET", "PUT", "POST", "PATCH", "DELETE", "OPTIONS");
16 }
17 };
18 }
1 public WebMvcConfigurer corsConfigurer() {
2 return new WebMvcConfigurer() {
3 @Override
4 public void addCorsMappings(CorsRegistry registry) {
5 registry.addMapping("/greeting-javaconfig").allowedOrigins("http://localhost:9000");
6 }
7 };
8 }Copy