Skip to content

Commit 00f61b2

Browse files
committed
more window guards
1 parent cee408c commit 00f61b2

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

ui/litellm-dashboard/src/app/dashboard/virtual-keys/components/VirtualKeysTable/VirtualKeysTable.tsx

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -105,18 +105,19 @@ const VirtualKeysTable = ({
105105

106106
// Add a useEffect to call refresh when a key is created
107107
useEffect(() => {
108-
if (refresh) {
109-
const handleStorageChange = () => {
110-
refresh();
111-
};
108+
if (!refresh || typeof window === "undefined") {
109+
return;
110+
}
111+
const handleStorageChange = () => {
112+
refresh();
113+
};
112114

113-
// Listen for storage events that might indicate a key was created
114-
window.addEventListener("storage", handleStorageChange);
115+
// Listen for storage events that might indicate a key was created
116+
window.addEventListener("storage", handleStorageChange);
115117

116-
return () => {
117-
window.removeEventListener("storage", handleStorageChange);
118-
};
119-
}
118+
return () => {
119+
window.removeEventListener("storage", handleStorageChange);
120+
};
120121
}, [refresh]);
121122

122123
const columns: ColumnDef<KeyResponse>[] = [

ui/litellm-dashboard/src/utils/cookieUtils.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
* Clears the token cookie from both root and /ui paths
77
*/
88
export function clearTokenCookies() {
9+
if (typeof window === "undefined" || typeof document === "undefined") {
10+
return;
11+
}
12+
913
// Get the current domain
1014
const domain = window.location.hostname;
1115

0 commit comments

Comments
 (0)