Files
OpenFrontIO/tests
Josh HarrisandGitHub ddc1abe146 Fix getApiBase() returning https://undefined when API_DOMAIN unset (#4685)
Resolves #4684

## Description:

Fixes `getApiBase()` returning `https://undefined` on `localhost` when
`API_DOMAIN` is unset (a plain `npm run dev`).

- `src/client/Api.ts`: use the exact `process.env.API_DOMAIN` form so
Vite's `define` replaces it (the previous `process?.env?.API_DOMAIN`
optional-chaining form wasn't matched, leaving the literal string
`"undefined"`).
- `vite.config.ts`: `JSON.stringify(env.API_DOMAIN ?? "")` so an unset
value becomes a falsy empty string instead of the truthy string
`"undefined"`.

Net: an unset `API_DOMAIN` now falls back to `http://localhost:8787` as
intended.

## Please complete the following:

- [x] I have added screenshots for all UI updates — _no UI changes_
- [x] I process any text displayed to the user through translateText()
and I've added it to the en.json file — _no user-facing text_
- [x] I have added relevant tests to the test directory — new
`tests/Api.test.ts` reproduces `https://undefined` (RED) and asserts the
`http://localhost:8787` fallback (GREEN); full suite green (2149 tests)

## Please put your Discord username so you can be contacted if a bug or
regression is found:

_⚠️ maintainer to fill_

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_01BWxUzYb2uqjcBFQuNSJhMy
2026-07-23 12:58:37 +01:00
..