Skip to content

Commit

Permalink
Merge pull request #91 from cathaaaaand/dev
Browse files Browse the repository at this point in the history
CORS ์ˆ˜์ •
  • Loading branch information
EUNCHAEv1006 authored Apr 29, 2024
2 parents 6b7fd45 + e02590f commit 081c0cc
Showing 1 changed file with 3 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
import org.springframework.web.cors.CorsConfigurationSource;
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;

import java.util.List;

@Configuration
@RequiredArgsConstructor
public class WebSecurityConfig {
Expand Down Expand Up @@ -71,13 +69,9 @@ public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Excepti
.anyRequest().authenticated() // ๋‚˜๋จธ์ง€ ๊ฒฝ๋กœ๋Š” ์ธ์ฆ ํ•„์š”
)
.addFilterBefore(jwtAuthorizationFilter(), UsernamePasswordAuthenticationFilter.class) // JWT ์ธ์ฆ ํ•„ํ„ฐ ์ถ”๊ฐ€
.cors(cors -> cors.configurationSource(request -> {
CorsConfiguration corsConfiguration = new CorsConfiguration();
corsConfiguration.setAllowedOrigins(List.of("http://localhost:8080", "https://www.wooriforei.info", "http://localhost:3000"));
corsConfiguration.setAllowedMethods(List.of("GET", "POST", "PUT", "DELETE", "OPTIONS"));
corsConfiguration.setAllowedHeaders(List.of("*"));
return corsConfiguration;
}));
.cors(cors -> cors.configurationSource(corsConfigurationSource())) // ์—ฌ๊ธฐ์„œ ๋žŒ๋‹ค ํ‘œํ˜„์‹ ์ œ๊ฑฐํ•˜๊ณ  ๋นˆ์„ ์ฐธ์กฐํ•˜๋„๋ก ๋ณ€๊ฒฝ
// .cors(cors -> cors.configurationSource(request -> { ... })) ๋ถ€๋ถ„์„ ์‚ญ์ œ
;
return http.build();
}
}

0 comments on commit 081c0cc

Please sign in to comment.