Guard getApiOrigin against undefined VITE_API#3332
Merged
Conversation
Refreshing the worker deployment versioning page in cloud-ui SSR threw TypeError because VITE_API is undefined in that environment and getApiOrigin called .startsWith on it. Return null early when VITE_API is undefined so base() produces an empty string and routeForApi produces a relative URL that SvelteKit's server-side fetch resolves correctly. Fixes COM-80
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
rossnelson
marked this pull request as ready for review
April 21, 2026 20:21
rossedfort
approved these changes
Apr 21, 2026
rossedfort
added a commit
that referenced
this pull request
Apr 22, 2026
Auto-generated version bump from 2.48.4 to 2.49.0 Bump type: minor Changes included: - [`9146199f`](9146199) fix: ref main in reusable PR review workflows (#3326) - [`ca904926`](ca90492) test(e2e): add end-to-end payload decoder coverage (#3321) - [`4e32d230`](4e32d23) chore: add setup-worktree skill (#3278) - [`a789fbdb`](a789fbd) Fix decoding payloads for user metadata (#3328) - [`21f2d448`](21f2d44) ci: remove unused Set up Protoc step from workflows (#3323) - [`39c41d25`](39c41d2) fix(ui): guard getApiOrigin against undefined VITE_API (#3332) - [`627cbb1b`](627cbb1) feat: add showInstancesLink prop to deployment header (#3331) - [`0726c65e`](0726c65) Check certFile modification time instead of keyFile (#3178) - [`8c79931b`](8c79931) feat(DT-3887): remove Dispatch Rate Epsilon from compute scaling UI (#3334) Co-authored-by: rossedfort <[email protected]>
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
Implements - Refreshing worker deployment versioning page throws error
On page refresh, the load function calls
fetchDeployment()→routeForApi()→base()→getApiOrigin(). During load, neitherpage.data?.webUrlnorglobalThis.AppConfig.apiUrlis available, sobase()falls through togetApiOrigin(). There,import.meta.env.VITE_APIisundefinedin cloud-ui consumer environments, causingTypeError: Cannot read properties of undefined (reading 'startsWith').Fix: add
if (endpoint === undefined) return null;guard before thestartsWithcall. Uses strict equality (not!endpoint) to preserve the existing behaviour whenVITE_APIis an empty string.Test plan
should return null when VITE_API is undefined— verifies no throw and null returnpnpm test -- --run: 137 files, 1798 tests)pnpm lintcleanpnpm checkno new errorspnpm build:serversucceeds