From 04adf03077544936e2e84bbc52850c44207e03ee Mon Sep 17 00:00:00 2001 From: Bytechoreographer Date: Thu, 16 Apr 2026 15:30:40 +0800 Subject: [PATCH] feat(ui): support NEXT_PUBLIC_LITELLM_PROXY_URL to override backend URL in dev The hardcoded localhost:4000 default in networking.tsx made it impossible to run the frontend dev server against a port-forwarded K8s backend without manually setting localStorage. Add NEXT_PUBLIC_LITELLM_PROXY_URL as the top-level override in defaultProxyBaseUrl. When set, all API calls (including the getUiConfig discovery request) go to that URL. Falls back to the existing localhost:4000 / NEXT_PUBLIC_USE_REWRITES logic unchanged. Also fix getUiConfig to use proxyBaseUrl instead of defaultProxyBaseUrl, so that litellm_worker_url set via localStorage is also respected for the initial discovery request. Co-Authored-By: Claude Sonnet 4 (1M context) --- ui/litellm-dashboard/src/components/networking.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ui/litellm-dashboard/src/components/networking.tsx b/ui/litellm-dashboard/src/components/networking.tsx index 16f35605877..b235c75ed2e 100644 --- a/ui/litellm-dashboard/src/components/networking.tsx +++ b/ui/litellm-dashboard/src/components/networking.tsx @@ -80,10 +80,13 @@ import NotificationsManager from "./molecules/notifications_manager"; const isLocal = process.env.NODE_ENV === "development"; // In dev, if NEXT_PUBLIC_USE_REWRITES=true the Next.js dev server proxies API calls // to the backend — use relative URLs (null) so rewrites can intercept them. +// NEXT_PUBLIC_LITELLM_PROXY_URL overrides the hardcoded localhost:4000 default, +// which is useful when running the frontend against a port-forwarded K8s backend. const defaultProxyBaseUrl = - isLocal && process.env.NEXT_PUBLIC_USE_REWRITES !== "true" + process.env.NEXT_PUBLIC_LITELLM_PROXY_URL ?? + (isLocal && process.env.NEXT_PUBLIC_USE_REWRITES !== "true" ? "http://localhost:4000" - : null; + : null); const defaultServerRootPath = "/"; export let serverRootPath = defaultServerRootPath; const WORKER_URL_KEY = "litellm_worker_url";