fix(react-client): prefix configured asset URLs with the app base path - #3036
Open
Bierbarbar wants to merge 1 commit into
Open
Bierbarbar wants to merge 1 commit into
Bierbarbar wants to merge 1 commit into
Conversation
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>
Bierbarbar
requested review from
asvishnyakov,
hayescode and
sandangel
as code owners
September 4, 2026 15:07
|
This PR is stale because it has been open for 14 days with no activity. |
This branch has not been deployed
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
logo_file_url,default_avatar_file_url,ChatProfile.icon, andlogin_page_imageare returned verbatim by the frontend whenever they're configured as a/public/...-relative path, bypassingapiClient.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:
(see
WelcomeScreen.tsx,Starter.tsx,ChatProfiles.tsx,ModePicker.tsx,ButtonLink.tsx) —buildEndpoint()is what correctly prependshttpEndpoint(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) — returnedconfiguredLogoUrlrawAvatar.tsx— returneddefault_avatar_file_urlandselectedChatProfile.iconrawLogin.tsx— returnedlogin_page_imagerawNo new abstraction, no behavior change for apps not deployed behind a subpath (an unprefixed
httpEndpointis a no-op prefix).Test plan
libs/react-client/src/api/index.spec.tscoveringgetLogoEndpoint: 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 testinlibs/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, andlogin_page_imagenow go throughapiClient.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
getLogoEndpointcovering base path prefixing, external URL passthrough, and the unconfigured fallback.Written for commit d65fc9e. Summary will update on new commits.