-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix(#64): cors 적용 에러 #65
The head ref may contain hidden characters: "fix/#64-cors-\uC801\uC6A9-\uC5D0\uB7EC"
Conversation
Test Results57 tests 56 ✅ 2s ⏱️ Results for commit ed25b65. ♻️ This comment has been updated with latest results. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
고생하셨습니다 !!
PR 제목이 컨벤션과 맞지않아요..!!
corsConfiguration.setAllowedOrigins(List.of(API_DOC_HOST, LOCAL_URL, JAKNAESO_WEB_VERCEL_APP)); | ||
corsConfiguration.setAllowedMethods(List.of("GET", "POST", "PUT", "PATCH", "DELETE")); | ||
corsConfiguration.addAllowedHeader("*"); | ||
corsConfiguration.setAllowCredentials(true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
저도 찾아보니까 이거 쿠키관련 설정이라고 하던데 저희 쿠키안쓰는데 true로 해야되는건가요 ??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
그렇네요. 쿠키 사용 안 하네요! 제거하도록 하겠습니다.
@@ -32,6 +34,7 @@ public SecurityFilterChain filterChain(HttpSecurity httpSecurity) throws Excepti | |||
.permitAll() | |||
.anyRequest() | |||
.authenticated()) | |||
.cors(corsConfigurer -> corsConfigurer.configurationSource(corsConfigurationSource)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이건 그냥 궁금해서 물어보는건데 제가 공식문서를 제대로 읽은건지 모르겠는데..기존 세팅에서
.cors(corsConfigurer -> corsConfigurer.configurationSource(corsConfigurationSource)) | |
.cors(withDefaults()) |
쓰면 저희 Mvc 설정 따라가는걸까요 ??
https://docs.spring.io/spring-security/reference/servlet/integrations/cors.html
해당문서참고했습니다 ! PR머지 후 확인해봐도 될것같습니다
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
넵 감사합니다! 확인해볼게요!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
민혁님 말씀이 맞는 것 같아요. withDefaults()
를 MVC 설정을 따라가는 것 같습니다. 이 메소드를 사용했으면 더 빨리 해결할 수 있었겠네요. 다만 CorsConfigurationSource
를 사용하면 조금 더 세밀한 설정이 가능하다는 장점이 있어서 CorsConfigurationSource
를 사용하는 게 좋다고 생각해요.
ex) API 엔드포인트별로 서로 다른 CORS 제어가 가능
작업 개요
문제 원인
WebMvcConfig
가 Spring Security에 의해 무시됨CorsConfig
를 사용하는 방식으로 수정