-
Notifications
You must be signed in to change notification settings - Fork 0
refactor(APIAdmin,APIUser): cors 해결 #38
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
The head ref may contain hidden characters: "refactor/#37-cors\uC758\uC874\uC131\uCD94\uAC00"
Conversation
Walkthrough
Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant ApiUserApplication
participant CorsConfig
participant OrderService
participant OrderCreateResponseDto
Client->>ApiUserApplication: 주문 생성 요청
ApiUserApplication->>OrderService: 주문 처리
OrderService-->>OrderCreateResponseDto: UserOrder 엔티티 전달
OrderCreateResponseDto-->>OrderService: sessionId 포함 응답 DTO 생성
OrderService-->>ApiUserApplication: 응답 DTO 반환
ApiUserApplication-->>Client: sessionId 포함 응답 반환
Note over ApiUserApplication, CorsConfig: CORS 허용 오리진에 63342 포트 추가 적용
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 0
🧹 Nitpick comments (1)
application-config/src/main/java/com/nowait/config/config/CorsConfig.java (1)
18-18: CORS 허용 오리진이 적절히 추가되었습니다.IntelliJ IDEA의 내장 웹 서버에서 사용하는 포트 63342가 허용 오리진에 추가되어 개발 환경에서의 CORS 문제가 해결됩니다.
개발 환경과 운영 환경을 구분하여 설정하는 것을 고려해보세요:
@Configuration public class CorsConfig { + @Value("${cors.allowed-origins:http://localhost:5173,http://localhost:63342}") + private String allowedOrigins; + @Bean public CorsConfigurationSource corsConfigurationSource() { CorsConfiguration config = new CorsConfiguration(); config.setAllowCredentials(true); - config.setAllowedOrigins(List.of("http://localhost:5173","http://localhost:63342")); + config.setAllowedOrigins(Arrays.asList(allowedOrigins.split(",")));
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
application-admin/build.gradle(1 hunks)application-admin/src/main/java/com/nowait/applicationadmin/ApiAdminApplication.java(1 hunks)application-config/src/main/java/com/nowait/config/config/CorsConfig.java(1 hunks)application-user/build.gradle(1 hunks)application-user/src/main/java/com/nowait/applicationuser/ApiUserApplication.java(1 hunks)application-user/src/main/java/com/nowait/applicationuser/order/dto/OrderCreateResponseDto.java(1 hunks)
🔇 Additional comments (6)
application-admin/build.gradle (1)
31-31: 의존성 추가가 올바르게 구현되었습니다.
:application-config의존성이 다른 프로젝트 의존성들과 일관된 패턴으로 추가되었으며, CORS 설정을 공유하기 위한 PR 목적에 부합합니다.application-user/build.gradle (1)
32-32: 의존성 추가가 일관되게 구현되었습니다.
application-admin모듈과 동일한 방식으로:application-config의존성이 추가되어 일관성을 유지하고 있습니다.application-admin/src/main/java/com/nowait/applicationadmin/ApiAdminApplication.java (1)
13-13: 컴포넌트 스캔 설정이 적절히 추가되었습니다.
com.nowait.config패키지를 스캔 범위에 포함시켜application-config모듈의 설정 빈들이 정상적으로 감지될 수 있도록 했습니다.application-user/src/main/java/com/nowait/applicationuser/ApiUserApplication.java (1)
14-14: 공유 설정을 위한 컴포넌트 스캔이 올바르게 추가되었습니다.
application-admin모듈과 동일하게com.nowait.config패키지가 스캔 범위에 포함되어 CORS 설정이 두 애플리케이션에서 공통으로 사용될 수 있습니다.application-user/src/main/java/com/nowait/applicationuser/order/dto/OrderCreateResponseDto.java (2)
18-18: 세션 ID 노출에 대한 보안 검토가 필요합니다.응답 DTO에
sessionId를 포함하는 것이 보안상 적절한지 검토해주세요. 세션 ID가 클라이언트에 노출되면 세션 하이재킹 등의 보안 위험이 있을 수 있습니다. CORS 설정과 관련된 변경이라면 대안적인 방법(예: CSRF 토큰, 별도의 식별자 등)을 고려해보시기 바랍니다.
26-26: UserOrder.getSessionId() 메서드 존재 확인 및 null 처리 검토
Lombok의@Getter어노테이션이 26번 라인에 적용되어 있어getSessionId()가 자동 생성되므로 호출이 정상 동작합니다.
필요 시 null 값에 대한 별도 처리가 필요하다면 다음을 고려하세요:
- Optional 반환으로 변경
- 빈 문자열 혹은 기본값 대입
- 호출부에서
Objects.requireNonNullElse(order.getSessionId(), “”)등 활용• UserOrder.java (domain-order/src/main/java/com/nowait/order/entity/UserOrder.java)
– 26:@Getter
– 48:private String sessionId;
작업 요약
Issue Link
#37
문제점 및 어려움
해결 방안
Reference
Summary by CodeRabbit
신규 기능
버그 수정
기타