Skip to content

web: fail fast on missing VITE_API_URL instead of a stale AWS fallback - #200

Merged
sdunster merged 1 commit into
mainfrom
claude/aws-urls-codebase-7h26bj
Sep 4, 2026
Merged

web: fail fast on missing VITE_API_URL instead of a stale AWS fallback#200
sdunster merged 1 commit into
mainfrom
claude/aws-urls-codebase-7h26bj

Conversation

@sdunster

@sdunster sdunster commented Sep 4, 2026

Copy link
Copy Markdown
Member

Summary

  • getGraphQLEndpoint() (web/src/lib/api.ts) silently fell back to a hardcoded Lambda Function URL (https://xgwyxvdqtmtmto3uuz3pwxxkhy0snjye.lambda-url.ap-southeast-2.on.aws/) whenever VITE_API_URL was unset in a non-dev build.
  • That URL is stale — it doesn't match any currently deployed API Lambda — and it never actually fired for a real deploy, since deploy-prod.yml, deploy-test.yml, and deploy-preprod.yml all set VITE_API_URL before npm run build. It was a landmine (a production build missing the env var would silently point at a wrong/orphaned endpoint) rather than a useful safety net.
  • Replaced it with a thrown error, but scoped to a genuine production build (import.meta.env.PROD) only — the dev server and the vitest suite both run in a non-"development" mode too and rely on getGraphQLEndpoint() returning a stable placeholder URL to mock against, so those still get http://localhost:8000/.

Test plan

  • npx tsc -b — clean
  • npx vitest run src/period/PeriodEdit.test.tsx src/kiosk/KioskMain.test.tsx — 29 passed
  • npm run build with VITE_API_URL set — succeeds, bundle no longer contains the stale hardcoded URL
  • Confirmed via the built bundle that a production build without VITE_API_URL throws at runtime instead of silently using the stale URL

🤖 Generated with Claude Code

https://claude.ai/code/session_0184X4TnPQixSfgJw2UPdng6


Generated by Claude Code

getGraphQLEndpoint() silently fell back to a hardcoded Lambda Function
URL when VITE_API_URL was unset in a production build. That URL is
stale (doesn't match any currently deployed API Lambda) and never
actually fires in prod/test/preprod, since all three deploy workflows
set VITE_API_URL before building — so it was a landmine, not a safety
net. Throw instead, but only for a genuine production build
(import.meta.env.PROD): the dev server and the test suite both still
get a localhost placeholder, since vitest runs in non-"development"
mode and relies on getGraphQLEndpoint() returning a stable URL to mock.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0184X4TnPQixSfgJw2UPdng6
@sdunster
sdunster marked this pull request as ready for review September 4, 2026 20:39
@sdunster
sdunster merged commit 99064e3 into main Sep 4, 2026
1 check passed
@sdunster
sdunster deleted the claude/aws-urls-codebase-7h26bj branch September 4, 2026 20:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants