Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,17 @@ public class CorsConfig {
@Bean
public CorsConfigurationSource corsConfigurationSource() {
CorsConfiguration config = new CorsConfiguration();
// 모든 출처(도메인) 허용 - Vercel 프론트엔드 등 다양한 도메인에서 요청 가능
config.setAllowedOriginPatterns(List.of("*"));
// preflight(OPTIONS) 포함 모든 HTTP 메서드 허용
config.setAllowedMethods(List.of("GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS"));
// Authorization 등 모든 요청 헤더 허용
config.setAllowedHeaders(List.of("*"));
// 쿠키/인증 정보 포함 요청 허용
config.setAllowCredentials(true);

UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
// 모든 경로에 위 CORS 설정 적용
source.registerCorsConfiguration("/**", config);
return source;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ public class SecurityConfig {
@Bean
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
http
// CorsConfig에서 등록한 CORS 설정을 Spring Security 필터 체인에 적용
// 이 설정이 없으면 preflight(OPTIONS) 요청이 Security 단에서 차단되어 405 반환
.cors(cors -> cors.configurationSource(corsConfigurationSource))
.csrf(AbstractHttpConfigurer::disable)
.sessionManagement(session ->
Expand Down
2 changes: 1 addition & 1 deletion frontend/vercel.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"rewrites": [
{
"source": "/api/:path*",
"destination": "http://13.209.73.127:8080/api/:path*"
"destination": "https://api.piroin.com/api/:path*"
}
]
}
Loading