From 5b37b361d33fcd95961880beefe28c9d9f6f9485 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Sat, 7 Mar 2026 06:24:26 +0000 Subject: [PATCH] fix: Chat UI 404 when navigating to conversation getChatUrl() hardcoded /ui/chat which does not exist as a Next.js route in dev mode. Use NEXT_PUBLIC_BASE_URL to determine the correct prefix (/chat in dev, /ui/chat in production). Co-authored-by: Ishaan Jaff --- .../src/components/chat/ChatPage.tsx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/ui/litellm-dashboard/src/components/chat/ChatPage.tsx b/ui/litellm-dashboard/src/components/chat/ChatPage.tsx index 830fb128a8e..0a4edea52f3 100644 --- a/ui/litellm-dashboard/src/components/chat/ChatPage.tsx +++ b/ui/litellm-dashboard/src/components/chat/ChatPage.tsx @@ -49,10 +49,18 @@ function getGreeting(): string { return "Good evening"; } -// Build the chat UI URL respecting server root path (e.g. /litellm/ui/chat) +// Build the chat UI URL respecting server root path and basePath. +// In dev mode (Next.js dev server), routes live at /chat directly. +// When served by the proxy, static export is mounted under /ui, so the path +// becomes {serverRootPath}/ui/chat. Use NEXT_PUBLIC_BASE_URL to detect the +// prefix so the same code works in both environments. function getChatUrl(id?: string): string { + const base = process.env.NEXT_PUBLIC_BASE_URL ?? ""; + const trimmed = base.replace(/^\/+|\/+$/g, ""); + const uiPath = trimmed ? `/${trimmed}` : ""; const root = serverRootPath && serverRootPath !== "/" ? serverRootPath.replace(/\/+$/, "") : ""; - return id ? `${root}/ui/chat?id=${id}` : `${root}/ui/chat`; + const prefix = `${root}${uiPath}`; + return id ? `${prefix}/chat?id=${id}` : `${prefix}/chat`; } // Build the dashboard root URL