web: fail fast on missing VITE_API_URL instead of a stale AWS fallback - #200
Merged
Conversation
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
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
getGraphQLEndpoint()(web/src/lib/api.ts) silently fell back to a hardcoded Lambda Function URL (https://xgwyxvdqtmtmto3uuz3pwxxkhy0snjye.lambda-url.ap-southeast-2.on.aws/) wheneverVITE_API_URLwas unset in a non-dev build.deploy-prod.yml,deploy-test.yml, anddeploy-preprod.ymlall setVITE_API_URLbeforenpm 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.import.meta.env.PROD) only — the dev server and the vitest suite both run in a non-"development"mode too and rely ongetGraphQLEndpoint()returning a stable placeholder URL to mock against, so those still gethttp://localhost:8000/.Test plan
npx tsc -b— cleannpx vitest run src/period/PeriodEdit.test.tsx src/kiosk/KioskMain.test.tsx— 29 passednpm run buildwithVITE_API_URLset — succeeds, bundle no longer contains the stale hardcoded URLVITE_API_URLthrows at runtime instead of silently using the stale URL🤖 Generated with Claude Code
https://claude.ai/code/session_0184X4TnPQixSfgJw2UPdng6
Generated by Claude Code