Skip to content

Commit

Permalink
fix: isBrowser() to include check on window (#982)
Browse files Browse the repository at this point in the history
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:

- supabase/supabase-js#786
  • Loading branch information
salmoro authored Dec 16, 2024
1 parent 7242c55 commit 645f224
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/lib/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 645f224

Please sign in to comment.