Make public base path runtime-safe - #54
Merged
Merged
Conversation
There was a problem hiding this comment.
APPROVE
Summary
이 PR은 Billtap의 프론트엔드 번들을 런타임 시점의 public base path에 안전하게 동작하도록 개선합니다. GHCR에 게시된 단일 Docker 이미지가 /, /billtap, 또는 다른 프록시 경로에 마운트될 때 프론트엔드 자산을 다시 빌드할 필요 없이 동작하도록 합니다.
핵심 변경사항
1. Vite 빌드 설정 변경 (vite.config.ts)
base: appBasePath→base: "./"변경- 빌드 시점의 절대 경로 대신 런타임 시점의 상대 경로를 사용하도록 변경
- 정적 자산(JS, CSS, favicon)이 상대 경로로 로드되어 어느 경로에서든 동작
2. 런타임 base path 감지 (web/shared/basePath.ts)
- 빌드 시점 환경변수(
import.meta.env.BASE_URL) 제거 globalThis.location.pathname에서 실제 경로 추출하는 regex로 대체/app/,/checkout/,/portal/경로에서 prefix를 안정적으로 감지
3. HTML favicon 경로 변경
4. 서버 리다이렉트 강화 (internal/server/server.go)
/checkout와/portal핸들러에서 정적 파일 직접 서빙 제거- 항상
/app/...경로로 리다이렉트하도록 변경 - 런타임 prefix 감지의 안정성 보장
5. 테스트 추가
server_test.go: 체크아웃 리다이렉트 동작 테스트 추가smoke-web.mjs:PUBLIC_BASE_PATH하에서 호스티드 리다이렉트 검증 추가
검증 관찰사항
- ✅ Billing state: 변경 없음
- ✅ Webhook reliability: 변경 없음
- ✅ Safety: 결제 처리, 실제 카드 데이터, 시크릿 처리와 무관한 순수 배포 유연성 개선
- ✅ Backwards compatibility: 기존
PUBLIC_BASE_PATH설정 계속 지원 - ✅ Test coverage: 새로운 동작에 대한 단위 테스트 및 웜 스모크 테스트 추가
결론
이 PR은 배포 유연성을 개선하는 인프라 변경입니다. 빌링 상태, 웹훅 신뢰성, 보안 경계에 영향을 주지 않으며, 테스트와 문서가 적절히 업데이트되었습니다. PR #53의 서버사이드 prefix 처리와 함께 완전한 runtime-prefix 지원을 제공합니다.
Reviewed by Z.ai GLM via Claude Code Action
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.
Summary
/checkoutand/portalentrypoints into/app/...so runtime prefix detection is stablePUBLIC_BASE_PATHValidation
go test ./... -count=1npm run buildPUBLIC_BASE_PATH=/billtap BILLTAP_PUBLIC_BASE_URL=http://127.0.0.1:18080 BILLTAP_WEB_SMOKE_PORT=18080 npm run smoke:webDeployment note
PR #53 deployed a working server-side prefix layer, but the prebuilt GHCR image still needed this runtime-safe frontend adjustment so one published image can be mounted at
/,/billtap, or another proxy path without rebuilding.