Skip to content

Commit

Permalink
Merge pull request #35 from saessagMarket/feat/#34-local-cors-config
Browse files Browse the repository at this point in the history
로컬 개발을 위한 CORS 설정 추가
  • Loading branch information
ahyeonkong authored Jan 17, 2025
2 parents d87305e + 418ce35 commit b4de523
Showing 1 changed file with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,7 @@ public SecurityFilterChain filterChain(HttpSecurity httpSecurity) throws Excepti
.cors(cors -> cors.configurationSource(corsConfigurationSource()))
.csrf(AbstractHttpConfigurer::disable) // 개발 환경에서만 disable
.authorizeHttpRequests((auth) -> auth // 인가
.requestMatchers(
"/api/products/**", // 상품 관련 엔드포인트
"/api/sign-up", // 회원가입
"/api/sign-in" // 로그인
).permitAll()
.requestMatchers("/api/**").permitAll()
// .requestMatchers("/admin").hasRole("ADMIN") // 관리자
// .requestMatchers("/my/**").hasAnyRole("ADMIN", "USER") // 마이페이지
.anyRequest().authenticated() // 이외의 경로
Expand All @@ -55,6 +51,12 @@ public SecurityFilterChain filterChain(HttpSecurity httpSecurity) throws Excepti
@Bean
CorsConfigurationSource corsConfigurationSource() {
CorsConfiguration config = new CorsConfiguration();

// 개발 환경과 배포 환경 모두 설정
config.setAllowedOrigins(List.of(
"http://localhost:3000"
));

config.setAllowedOrigins(List.of(
"https://saessagmarket.netlify.app"
));
Expand Down

0 comments on commit b4de523

Please sign in to comment.