[FIX] lambda 환경 CORS 오류로 프론트엔드 API 호출 실패#411
Merged
Conversation
- SecurityConfig에 CorsConfigurationSource 빈 추가 - Lambda 프로파일용 setHttpLambda() 메서드 분리 - API Gateway CORS 설정 제거 (Spring에서 처리) EC2 환경에서는 Nginx가 CORS를 처리했으나, Lambda 환경에서는 Spring Security에서 직접 처리하도록 변경. 허용 Origin: *.sopt.org, localhost:* 허용 Credentials: true
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🔗 관련 이슈
Related to #393
📋 작업 내용 요약
Lambda 환경에서 CORS 오류로 프론트엔드 API 호출이 실패하는 문제 수정.
기존 EC2의 Nginx CORS 설정을 Spring Security에서 처리하도록 변경.
주요 변경사항
SecurityConfig에CorsConfigurationSource빈 추가setHttpLambda()메서드 분리 (.cors()활성화)template-dev.yaml에서 API Gateway CORS 설정 제거💡 구현 방법
1. CORS 설정 빈 추가 (SecurityConfig.java)
2. Lambda용 Security 설정 분리
setHttp()setHttpLambda()3. API Gateway CORS 비활성화
API Gateway의 Cors 섹션을 제거하여 OPTIONS 요청도 Lambda로 전달되도록 변경.
이를 통해 Spring의 CORS 설정이 모든 요청에 적용됨.
📸 스크린샷 / 실행 결과
수정 전
수정 후
🧪 테스트
테스트 케이스
테스트 시나리오
🔍 리뷰 포인트
setHttp()와setHttpLambda()분리가 적절한지allowedOriginPatterns패턴이 보안상 적절한지 (*.sopt.org)📝 추가 메모
EC2 vs Lambda CORS 처리 비교
$http_origin(동적)allowedOriginPatternstruetrue참고: 기존 Nginx 설정 (EC2)
✅ PR 체크리스트