Skip to content

Rallly is an open-source scheduling and collaboration tool designed to make organizing events and meetings easier.

🔒️ Handle when local storage isn’t available (#1457)

Luke Vella386231d56948
diff --git a/apps/web/src/utils/local-storage.ts b/apps/web/src/utils/local-storage.ts
index ca665e8de..bf62a4314 100644
--- a/apps/web/src/utils/local-storage.ts
+++ b/apps/web/src/utils/local-storage.ts
@@ -7,8 +7,21 @@ class LocalStorage {
private isLocalStorageAvailable: boolean;
constructor() {
- this.isLocalStorageAvailable =
- typeof window !== "undefined" && !!window.localStorage;
+ this.isLocalStorageAvailable = this.checkLocalStorageAvailability();
+ }
+
+ private checkLocalStorageAvailability(): boolean {
+ try {
+ if (typeof window === "undefined") return false;
+
+ // Test localStorage by actually trying to use it
+ const testKey = "__storage_test__";
+ localStorage.setItem(testKey, testKey);
+ localStorage.removeItem(testKey);
+ return true;
+ } catch (e) {
+ return false;
+ }
}
getItem(key: string): string | null {