Repository navigation
fix(proxy): serve dashboard routes from flat Next.js exports without restructuring - #35751
Open
davesheffer wants to merge 1 commit into
Open
davesheffer wants to merge 1 commit into
davesheffer wants to merge 1 commit into
Conversation
…restructuring Next.js exports built without trailingSlash emit chat.html plus an index-less chat/ data directory. StaticFiles(html=True) matches the directory first, looks for chat/index.html, and 404s direct navigation to /ui/chat. The startup restructure that compensates for this needs a writable filesystem, so read-only deployments keep returning 404. Resolve the fallback at lookup time instead: when <route>/index.html is missing, serve the sibling <route>.html. Both export layouts now work as-is with zero writes to disk at startup. Fixes BerriAI#24037
Contributor
Greptile SummaryThis PR adds a Starlette static-file subclass that serves flat Next.js route exports without startup filesystem writes and switches the dashboard mount to use it
Confidence Score: 5/5The PR appears safe to merge; the fallback preserves standard static-file behavior while resolving flat dashboard exports Starlette’s directory-index lookup reaches the new fallback for index-less route directories, and every retry still passes through the framework’s normal path-resolution and containment checks
|
| Filename | Overview |
|---|---|
| litellm/proxy/common_utils/ui_static_files.py | Adds a contained lookup fallback for flat Next.js HTML exports while preserving Starlette’s standard resolution and path protections |
| litellm/proxy/proxy_server.py | Replaces the /ui static mount with the specialized subclass without changing startup restructuring behavior |
| tests/test_litellm/proxy/common_utils/test_ui_static_files.py | Provides focused regression coverage for both export layouts, shadowing directories, assets, missing routes, and the no-write requirement |
Reviews (1): Last reviewed commit: "fix(proxy): serve dashboard routes from ..." | Re-trigger Greptile
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Contributor
Closed
1 task done
devin-ai-integration
Bot
changed the base branch from
litellm_internal_staging
to
main
September 23, 2026 15:18
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.
TLDR
Problem this solves:
How it solves it:
<route>.htmlwhen<route>/index.htmlis missingRelevant issues
Fixes #24037
Linear ticket
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
osv-scan, which is the pre-existing cryptography CVE failure that has been red on every branch since 2026-08-03 and is fixed by fix(deps): bump cryptography to 49.0.0 to clear osv-flagged CVEs #35759; it is unrelated to this PR@greptileaito re-request a review after pushing changes)Delays in PR merge?
If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).
Screenshots / Proof of Fix
The failing deployment shape from the issue is a UI bundle in the pre-trailingSlash layout (
chat.htmlnext to an index-lesschat/RSC data directory) served from a location where the startup restructure cannot run, which is what a read-only pod filesystem looks like in practice. To reproduce it locally I copiedlitellm/proxy/_experimental/out, moved each route'sindex.htmlback to a sibling<route>.html, and dropped a.litellm_ui_readymarker so startup skips the restructure, exactly like a read-only filesystem wouldBoth runs start the proxy the same way and hit it with plain curl:
Before, at a625d1e:
curl -i http://localhost:4000/ui/chatreturnsHTTP/1.1 404 Not Foundwith the Next.js<title>404: This page could not be found.</title>page, which is exactly what users report in #24037After, at 6257a6c:
After serving,
flat_ui/chat/still has noindex.htmlandchat.htmlis still at the top level, confirming the proxy wrote nothing to the bundleType
🐛 Bug Fix
Changes
StaticFiles(html=True)resolves/ui/chatby matching thechat/directory first and looking forchat/index.html; the siblingchat.htmlis never tried, so the request 404s. The existing compensation moves files around at startup (_restructure_ui_html_files), but it only runs when the UI directory is writable, so read-only deployments serving a flat bundle keep failing, as reported on the issue as recently as v1.90.0This PR adds
UiStaticFilesinlitellm/proxy/common_utils/ui_static_files.py, aStaticFilessubclass that falls back at lookup time: when a lookup misses, it retries<route>/index.htmlas<route>.html, and a plain extensionless miss as<route>.html. The/uimount inproxy_server.pynow uses it. Restructured bundles resolve on the first lookup and never reach the fallback, flat bundles resolve on the retry, and nothing is written to disk either wayTests in
tests/test_litellm/proxy/common_utils/test_ui_static_files.pycover the flat layout with and without the shadowing directory, the restructured layout, the guarantee that serving writes nothing to disk, plain asset files, and unknown routes still returning 404. The flat-layout cases fail against vanillaStaticFiles, so a regression of #24037 fails the suiteFinal Attestation