✅ CORS란?
이 설정은 JWT 기반 인증 구조에서 프론트엔드(React 등)와 백엔드(Spring)가 다른 도메인/포트에 존재할 경우 기본적인 CORS 문제를 방지하기 위해 필요하다.
@Bean
public CorsConfigurationSource corsConfigurationSource() {
CorsConfiguration config = new CorsConfiguration();
config.setAllowedOrigins(List.of("http://localhost:3000"));
config.setAllowedMethods(List.of("GET", "POST", "PUT", "DELETE", "OPTIONS"));
config.setAllowedHeaders(List.of("*"));
config.setAllowCredentials(true);
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
source.registerCorsConfiguration("/**", config);
return source;
}