Tag Archives: cors

[펌글] Spring Security 에서의 CORS 설정

By | 6월 29, 2021

spring security config 클래스 @EnableWebSecurity public class CustomSecurityConfig extends WebSecurityConfigurerAdapter { … @Override protected void configure(HttpSecurity http) throws Exception { http … .and() .authorizeRequests() .requestMatchers(CorsUtils::isPreFlightRequest).permitAll() // cors setting 1 … .and().cors(); // cors setting 2 } // cors setting 3 @Bean public CorsConfigurationSource corsConfigurationSource() { CorsConfiguration configuration = new CorsConfiguration(); // configuration.addAllowedOrigin("*"); configuration.addAllowedOrigin("http://localhost:3000"); configuration.addAllowedMethod("*"); configuration.addAllowedHeader("*");… Read More »