Skip to content

Commit

Permalink
[#2]๐Ÿ›Fix: CORS ์ˆ˜์ •
Browse files Browse the repository at this point in the history
  • Loading branch information
sumin220 committed Nov 22, 2024
1 parent 2f73f78 commit 9712c82
Showing 1 changed file with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Excepti
.formLogin(AbstractHttpConfigurer::disable)
.httpBasic(AbstractHttpConfigurer::disable)

// iframe ์ฐจ๋‹จ
.headers(header -> header.frameOptions(
HeadersConfigurer.FrameOptionsConfig::sameOrigin
))
// // iframe ์ฐจ๋‹จ
// .headers(header -> header.frameOptions(
// HeadersConfigurer.FrameOptionsConfig::sameOrigin
// ))

// session ์‚ฌ์šฉ ์ค‘์ง€
.sessionManagement(session -> session.sessionCreationPolicy(SessionCreationPolicy.STATELESS))
Expand Down Expand Up @@ -99,15 +99,15 @@ public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Excepti
.build();
}

@Value("${cors.allowed-origins:http://localhost:3000}")
private List<String> allowOriginList;
// @Value("${cors.allowed-origins")
// private List<String> allowOriginList;

@Bean
public CorsConfigurationSource corsConfigurationSource() {
CorsConfiguration configuration = new CorsConfiguration();
configuration.setAllowedOrigins(allowOriginList); // ํ—ˆ์šฉํ•  Origin ์ถ”๊ฐ€
configuration.setAllowedMethods(List.of("GET", "POST", "PUT", "DELETE", "OPTIONS"));
configuration.setAllowedHeaders(List.of("*"));
configuration.addAllowedOrigin("http://localhost:3000"); // ํด๋ผ์ด์–ธํŠธ ์ฃผ์†Œ
configuration.addAllowedMethod("*");
configuration.addAllowedHeader("*");
configuration.setAllowCredentials(true);
configuration.addExposedHeader("Authorization");
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
Expand Down

0 comments on commit 9712c82

Please sign in to comment.