From 40eaab5693df1b695a6c6281309fb661a4673b3d Mon Sep 17 00:00:00 2001 From: Hendrik Jaks Date: Fri, 20 Mar 2026 00:07:06 +0200 Subject: [PATCH] refactor(ui): remove circular dependency in cookieUtils.ts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Derive the UI cookie path from window.location.pathname instead of importing serverRootPath from networking.tsx. This breaks the cookieUtils → networking → cookieUtils cycle that could cause serverRootPath to be undefined under certain bundler configurations. Co-Authored-By: Claude Opus 4.6 (1M context) --- ui/litellm-dashboard/src/utils/cookieUtils.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/ui/litellm-dashboard/src/utils/cookieUtils.ts b/ui/litellm-dashboard/src/utils/cookieUtils.ts index 928f640fc2d..583f41e84a8 100644 --- a/ui/litellm-dashboard/src/utils/cookieUtils.ts +++ b/ui/litellm-dashboard/src/utils/cookieUtils.ts @@ -1,16 +1,18 @@ /** * Utility functions for managing cookies */ -import { serverRootPath } from "@/components/networking"; /** * Returns the cookie path for the UI. - * Respects server_root_path so the cookie works when LiteLLM is - * deployed behind a subpath (e.g. /myapp/ui instead of /ui). + * Derives the path from window.location.pathname so it works when + * LiteLLM is deployed behind a subpath (e.g. /myapp/ui instead of /ui). + * No imports from networking.tsx to avoid circular dependencies. */ function getUiCookiePath(): string { - const root = serverRootPath === "/" ? "" : serverRootPath; - return `${root}/ui`; + if (typeof window === "undefined") return "/ui"; + const idx = window.location.pathname.indexOf("/ui"); + if (idx >= 0) return window.location.pathname.substring(0, idx + 3); + return "/ui"; } /**