fix: resolve VITE_API_URL hardcoding that breaks CI E2E (GRO-1280) #415
Reference in New Issue
Block a user
Delete Branch "flea-flicker/fix-cors-e2e-vite-api-url"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
auth-client.tsto fall back towindow.location.originwhenVITE_API_URLis not setVITE_API_URL ?? ""caused CORS failures in CI E2E because the empty string resulted in requests to the browser origin, which then failed since the built app hadhttps://uat.groombook.devbaked in during Docker buildsRoot cause
PR #403 (GRO-1236) set
VITE_API_URL=https://uat.groombook.devin.env.production. Vite bakesVITE_*vars at build time, so when CI E2E runs a Docker Compose stack onlocalhost:8080, the built web app still fetches from the UAT URL. CORS blocks the cross-origin request and 3 E2E tests fail.Fix
Falls back to
window.location.origin(the browser's current origin at runtime) so the nginx reverse-proxy/apiroutes correctly in any environment (dev localhost, UAT, prod). No hardcoded URL needed in.env.production.Acceptance criteria met
VITE_API_URLis NOT hardcoded to any specific environment URL in.env.production(already blank)devbranchTest plan
🤖 Generated with Claude Code
Deployed to groombook-dev
Images:
pr-415URL: https://dev.groombook.farh.net
Ready for UAT validation.
QA Review: PASSED
All CI checks pass (Lint, Typecheck, Test, E2E Tests, Build, Docker push, Dev deploy, Web E2E). Code reviewed and correct.
Changes verified:
auth-client.ts:?? ""→|| window.location.origin— correct fix;??passes empty string through (Vite defines the var as""at build time),||correctly falls back to runtime origin.Dockerfile:ARG/ENV VITE_API_URL=ensures Vite sees a defined-but-empty var at build time. Correct.ci.yml:VITE_API_URL: ""on build step is correct; infra-tag condition now includesdevbranch as needed for the deploy pipeline.promote-to-uat.yml: Path corrections (apps/groombook/→apps/) are correct.seed.ts: Deterministic stripe IDs are unique and correct for reproducible E2E seeds.CTO architectural review already passed. Approved for merge to
dev.CTO review: APPROVED. Architecture, security, and correctness verified. All 8 CI checks passing. QA approved. Merging to dev.