From 158ea808e611e9f4853cf470d15d535578688efa Mon Sep 17 00:00:00 2001 From: happybell80 Date: Mon, 11 Aug 2025 21:46:40 +0900 Subject: [PATCH] =?UTF-8?q?docs:=20Frontend=20=EB=B9=8C=EB=93=9C=20?= =?UTF-8?q?=ED=99=98=EA=B2=BD=EB=B3=80=EC=88=98=20=EB=AC=B8=EC=A0=9C=20?= =?UTF-8?q?=ED=8A=B8=EB=9F=AC=EB=B8=94=EC=8A=88=ED=8C=85=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Gitea Actions에서 VITE_ROBING_API_URL 누락 발견 - 빌드 시점 환경변수 미적용으로 기본값 사용 - 근본 원인 해결 방법 문서화 --- ...1_happybell80_Gateway필드변환문제.md | 51 ++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/troubleshooting/250811_happybell80_Gateway필드변환문제.md b/troubleshooting/250811_happybell80_Gateway필드변환문제.md index 24f9475..0ec80a7 100644 --- a/troubleshooting/250811_happybell80_Gateway필드변환문제.md +++ b/troubleshooting/250811_happybell80_Gateway필드변환문제.md @@ -134,4 +134,53 @@ class MessageRequest(BaseModel): 1. **즉시**: rb10508_micro에 message 필드 지원 추가 2. **긴급**: JWT 토큰 검증 구현 3. **계획**: Gateway 스케일링 전략 수립 -4. **장기**: Service Mesh 도입 검토 \ No newline at end of file +4. **장기**: Service Mesh 도입 검토 + +--- + +## 오후 9:42 + +### 문제 5: Frontend 빌드 시 환경변수 미적용 + +**증상**: +- .env 파일에 `VITE_ROBING_API_URL=https://ro-being.com/gateway` 설정됨 +- 하지만 빌드된 JS 파일에는 하드코딩 기본값 `/rb10508` 사용 +- 결과: nginx가 Gateway 우회하여 직접 프록시 + +**원인 발견**: +```yaml +# .gitea/workflows/deploy.yml +- name: Build application + run: | + export VITE_API_URL=http://localhost:8001 + # VITE_ROBING_API_URL 누락! + npm run build +``` + +**해결**: +```yaml +export VITE_API_URL=http://localhost:8001 +export VITE_ROBING_API_URL=https://ro-being.com/gateway # 추가 +npm run build +``` + +### 교훈 + +1. **빌드 환경변수 체크** + - CI/CD 스크립트에서 모든 환경변수 설정 확인 + - .env 파일이 있어도 빌드 시점에 로드되는지 검증 + - 빌드된 결과물에서 실제 값 확인 + +2. **기본값 함정** + - 하드코딩 기본값은 디버깅을 어렵게 만듦 + - 환경변수 미설정 시 명확한 에러가 낫다 + +3. **근본 원인 vs 임시방편** + - rb10508_micro 수정은 임시방편 + - Gitea Actions 수정이 근본 해결 + - 구조적으로 올바른 해결 우선 + +4. **서버 관리자 관점** + - Gateway가 이미 모든 기능 제공 + - 직접 프록시는 필드 변환 누락 + - Gateway 경유가 정석 \ No newline at end of file