fix(react-client): prefix configured asset URLs with the app base path

Closed
BI
2mo ago
+43-6

Summary

logo_file_url, default_avatar_file_url, ChatProfile.icon, and login_page_image are returned verbatim by the frontend whenever they're configured as a /public/...-relative path, bypassing apiClient.buildEndpoint() entirely. This breaks under a reverse-proxy subpath deployment (e.g. https://host/my-app/...): the browser requests the unprefixed path against the domain root, which never reaches the app.

Several sibling call sites already guard against exactly this with the same pattern:

value.startsWith('/public') ? apiClient.buildEndpoint(value) : value

(see WelcomeScreen.tsx, Starter.tsx, ChatProfiles.tsx, ModePicker.tsx, ButtonLink.tsx) — buildEndpoint() is what correctly prepends httpEndpoint (window.origin + basename), so an already-absolute external URL is left untouched while a local /public/... path gets the app's base path prepended.

This PR applies the same, already-established guard to the three places that were missing it:

  • ChainlitAPI.getLogoEndpoint() (libs/react-client/src/api/index.tsx) — returned configuredLogoUrl raw
  • Avatar.tsx — returned default_avatar_file_url and selectedChatProfile.icon raw
  • Login.tsx — returned login_page_image raw

No new abstraction, no behavior change for apps not deployed behind a subpath (an unprefixed httpEndpoint is a no-op prefix).

Test plan

  • Added libs/react-client/src/api/index.spec.ts covering getLogoEndpoint: prefixes a /public/... path, leaves an external URL untouched, and the unconfigured fallback still works. Matches the existing unit-test convention in this package (state.spec.ts) — the project otherwise relies on Cypress E2E rather than component unit tests, and adding an E2E fixture for this would have required changes to the shared test runner (no per-scenario env var support today), which felt like scope creep for a 3-site fix.
  • pnpm lint, pnpm format-check, pnpm type-check (whole repo) all pass.
  • pnpm test in libs/react-client: 19/19 passing.

🤖 Generated with Claude Code


Summary by cubic

Fixes configured asset URLs being returned without the app base path when set to a /public/... path, which broke logo, avatar, and login page image loading under reverse-proxy subpath deployments. logo_file_url, default_avatar_file_url, ChatProfile.icon, and login_page_image now go through apiClient.buildEndpoint() when they start with /public; external URLs and unconfigured fallbacks behave as before, and apps not deployed behind a subpath see no change.

Adds unit tests for getLogoEndpoint covering base path prefixing, external URL passthrough, and the unconfigured fallback.