diff --git a/src/GoTrueClient.ts b/src/GoTrueClient.ts index 0afd4710c..888704219 100644 --- a/src/GoTrueClient.ts +++ b/src/GoTrueClient.ts @@ -1198,6 +1198,11 @@ export default class GoTrueClient { throw error } + if (!data.session?.access_token) { + // if there's no access token, the user can't be fetched + return { data: { user: null }, error: new AuthSessionMissingError() } + } + return await _request(this.fetch, 'GET', `${this.url}/user`, { headers: this.headers, jwt: data.session?.access_token ?? undefined,