more window guards

This commit is contained in:
Achintya Rajan 2025-10-06 14:17:02 -07:00
parent cee408c0c0
commit 00f61b214c
2 changed files with 16 additions and 11 deletions

View file

@ -105,18 +105,19 @@ const VirtualKeysTable = ({
// Add a useEffect to call refresh when a key is created
useEffect(() => {
if (refresh) {
const handleStorageChange = () => {
refresh();
};
// Listen for storage events that might indicate a key was created
window.addEventListener("storage", handleStorageChange);
return () => {
window.removeEventListener("storage", handleStorageChange);
};
if (!refresh || typeof window === "undefined") {
return;
}
const handleStorageChange = () => {
refresh();
};
// Listen for storage events that might indicate a key was created
window.addEventListener("storage", handleStorageChange);
return () => {
window.removeEventListener("storage", handleStorageChange);
};
}, [refresh]);
const columns: ColumnDef<KeyResponse>[] = [

View file

@ -6,6 +6,10 @@
* Clears the token cookie from both root and /ui paths
*/
export function clearTokenCookies() {
if (typeof window === "undefined" || typeof document === "undefined") {
return;
}
// Get the current domain
const domain = window.location.hostname;