diff --git a/crescendo-server/src/main/java/com/example/crescendoserver/global/config/security/SecurityConfig.java b/crescendo-server/src/main/java/com/example/crescendoserver/global/config/security/SecurityConfig.java index 34fc184..75655cf 100644 --- a/crescendo-server/src/main/java/com/example/crescendoserver/global/config/security/SecurityConfig.java +++ b/crescendo-server/src/main/java/com/example/crescendoserver/global/config/security/SecurityConfig.java @@ -15,6 +15,10 @@ import org.springframework.security.crypto.password.PasswordEncoder; import org.springframework.security.web.SecurityFilterChain; import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; +import org.springframework.web.cors.CorsConfiguration; +import org.springframework.web.cors.CorsConfigurationSource; + +import java.util.Collections; @Configuration @RequiredArgsConstructor @@ -72,4 +76,15 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { .addFilterBefore(jwtExceptionFilter, JwtAuthenticationFilter.class) .build(); } + + CorsConfigurationSource corsConfigurationSource() { + return request -> { + CorsConfiguration config = new CorsConfiguration(); + config.setAllowedHeaders(Collections.singletonList("*")); + config.setAllowedMethods(Collections.singletonList("*")); + config.setAllowedOriginPatterns(Collections.singletonList("*")); + config.setAllowCredentials(true); + return config; + }; + } }