Skip to content

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

Open
Bierbarbar wants to merge 1 commit into
Chainlit:mainfrom
Bierbarbar:fix/asset-url-root-path-prefix
Open

Bierbarbar wants to merge 1 commit into
Chainlit:mainfrom
Bierbarbar:fix/asset-url-root-path-prefix

Conversation

@Bierbarbar

@Bierbarbar Bierbarbar commented Sep 4, 2026

Copy link
Copy Markdown

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.

Written for commit d65fc9e. Summary will update on new commits.

Review in cubic

logo_file_url, default_avatar_file_url, ChatProfile.icon, and
login_page_image were returned verbatim when set to a /public/... path,
bypassing apiClient.buildEndpoint() and breaking under a reverse-proxy
subpath (window.origin + basename never gets prepended). Several
sibling call sites (WelcomeScreen, Starter, ChatProfiles) already guard
with `startsWith('/public') ? buildEndpoint(url) : url` — this applies
the same guard to the three places that were missing it.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 4 files

Re-trigger cubic

@github-actions

Copy link
Copy Markdown

This PR is stale because it has been open for 14 days with no activity.

@github-actions github-actions Bot added the stale Issue has not had recent activity or appears to be solved. Stale issues will be automatically closed label Sep 19, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stale Issue has not had recent activity or appears to be solved. Stale issues will be automatically closed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant