mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-09 03:18:44 +00:00
refactor(ui): remove circular dependency in cookieUtils.ts
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) <noreply@anthropic.com>
This commit is contained in:
parent
bd878e742e
commit
40eaab5693
1 changed files with 7 additions and 5 deletions
|
|
@ -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";
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue