mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-08 03:08:45 +00:00
add cookieUtils
This commit is contained in:
parent
19411fbcc7
commit
2ea7b975c2
1 changed files with 28 additions and 0 deletions
28
ui/litellm-dashboard/src/utils/cookieUtils.ts
Normal file
28
ui/litellm-dashboard/src/utils/cookieUtils.ts
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
/**
|
||||
* Utility functions for managing cookies
|
||||
*/
|
||||
|
||||
/**
|
||||
* Clears the token cookie from both root and /ui paths
|
||||
*/
|
||||
export function clearTokenCookies() {
|
||||
// Clear token cookie on root path
|
||||
document.cookie = "token=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
|
||||
|
||||
// Clear token cookie on /ui path
|
||||
document.cookie = "token=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/ui;";
|
||||
|
||||
console.log("After clearing cookies:", document.cookie);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a cookie value by name
|
||||
* @param name The name of the cookie to retrieve
|
||||
* @returns The cookie value or null if not found
|
||||
*/
|
||||
export function getCookie(name: string) {
|
||||
const cookieValue = document.cookie
|
||||
.split('; ')
|
||||
.find(row => row.startsWith(name + '='));
|
||||
return cookieValue ? cookieValue.split('=')[1] : null;
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue