diff --git a/src/GoTrueClient.ts b/src/GoTrueClient.ts index 0e0c880d..5aafb625 100644 --- a/src/GoTrueClient.ts +++ b/src/GoTrueClient.ts @@ -1524,9 +1524,13 @@ export default class GoTrueClient { * Checks if the current URL contains parameters given by an implicit oauth grant flow (https://www.rfc-editor.org/rfc/rfc6749.html#section-4.2) */ private _isImplicitGrantFlow(): boolean { + if (!isBrowser()) { + return false + } + const params = parseParametersFromURL(window.location.href) - return !!(isBrowser() && (params.access_token || params.error_description)) + return !!(params.access_token || params.error_description) } /** diff --git a/src/lib/helpers.ts b/src/lib/helpers.ts index 22e22c97..d940d1b4 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,