Skip to content

Commit 9e57ade

Browse files
committed
Deploy: Cors Bean 객체 생성
1 parent 9d1ea96 commit 9e57ade

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

backend/src/main/java/com/together/backend/global/config/SecurityConfig.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
import org.springframework.security.web.SecurityFilterChain;
1717
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
1818
import lombok.extern.slf4j.Slf4j;
19+
import org.springframework.web.cors.CorsConfiguration;
20+
import org.springframework.web.cors.CorsConfigurationSource;
21+
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
1922

2023
@Slf4j
2124
@Configuration
@@ -27,6 +30,21 @@ public class SecurityConfig {
2730
private final CustomSuccessHandler customSuccessHandler;
2831
private final JWTUtil jwtUtil;
2932

33+
@Bean
34+
public CorsConfigurationSource corsConfigurationSource() {
35+
CorsConfiguration config = new CorsConfiguration();
36+
config.setAllowCredentials(true);
37+
config.addAllowedOrigin("https://7-together.kro.kr");
38+
config.addAllowedOrigin("http://localhost:3000");
39+
config.addAllowedHeader("*");
40+
config.addAllowedMethod("*");
41+
config.addExposedHeader("Set-Cookie");
42+
43+
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
44+
source.registerCorsConfiguration("/**", config);
45+
return source;
46+
}
47+
3048
@Bean
3149
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
3250
http

0 commit comments

Comments
 (0)