Skip to content

Commit

Permalink
Merge pull request #10 from Co-due/feature/issue9
Browse files Browse the repository at this point in the history
[#9]deploy: CORS 설정 reactive 방식으로 수정
  • Loading branch information
SongGwanSeok authored Sep 4, 2024
2 parents 2be3934 + f15aaa2 commit c47d25a
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 18 deletions.
34 changes: 34 additions & 0 deletions src/main/java/soma/haeya/edupi_gateway/config/CorsConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package soma.haeya.edupi_gateway.config;

import java.util.List;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.reactive.CorsConfigurationSource;
import org.springframework.web.cors.reactive.CorsWebFilter;
import org.springframework.web.cors.reactive.UrlBasedCorsConfigurationSource;

@Configuration
public class CorsConfig {

@Bean
public CorsWebFilter corsWebFilter() {
return new CorsWebFilter(corsConfigurationSource());
}

@Bean
public CorsConfigurationSource corsConfigurationSource() {
CorsConfiguration configuration = new CorsConfiguration();
configuration.setAllowedOrigins(List.of("*"));
configuration.setAllowedMethods(List.of("GET", "POST", "PUT", "DELETE", "OPTIONS"));
configuration.setAllowedHeaders(List.of("*"));
configuration.setAllowCredentials(true);
configuration.setMaxAge(3600L);

UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
source.registerCorsConfiguration("/**", configuration);

return source;
}

}
18 changes: 0 additions & 18 deletions src/main/java/soma/haeya/edupi_gateway/config/SecurityConfig.java

This file was deleted.

0 comments on commit c47d25a

Please sign in to comment.