From 645f22447e68ba13e43e359d1524e95fe025d771 Mon Sep 17 00:00:00 2001 From: Shlomo Morosow Date: Mon, 16 Dec 2024 11:02:02 -0500 Subject: [PATCH] fix: `isBrowser()` to include check on `window` (#982) There are several checks in `GoTrueClient.ts` that check `window?.[prop]` after checking `isBrowser()` which throws an error in node environments that have `document` defined but not `window`. Fixes: - https://github.com/supabase/supabase-js/issues/786 --- src/lib/helpers.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lib/helpers.ts b/src/lib/helpers.ts index 22e22c978..d940d1b42 100644 --- a/src/lib/helpers.ts +++ b/src/lib/helpers.ts @@ -14,7 +14,8 @@ export function uuid() { }) } -export const isBrowser = () => typeof document !== 'undefined' +export const isBrowser = () => + typeof window !== 'undefined' && typeof document !== 'undefined' const localStorageWriteTests = { tested: false,