Skip to content

Conversation

soedirgo
Copy link
Member

When initializing SupabaseClient, if the Authorization header is provided, it will be used for _getAuthHeaders() instead of the session's access token or Supabase key.

@soedirgo soedirgo requested a review from thorwebdev March 22, 2022 23:13
Copy link
Contributor

@thorwebdev thorwebdev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks

@thorwebdev thorwebdev merged commit 41d6113 into master Mar 22, 2022
@thorwebdev thorwebdev deleted the fix/auth-bearer-override branch March 22, 2022 23:59
@maxkostow
Copy link
Contributor

This causes the Authorization header to be cached even after auth refreshes the access_token. This should probably clone the headers object before assigning the properties.

  private _getAuthHeaders(): GenericObject {
    const headers: GenericObject = { ...this.headers }
    const authBearer = this.auth.session()?.access_token ?? this.supabaseKey
    headers['apikey'] = this.supabaseKey
    headers['Authorization'] = headers['Authorization'] || `Bearer ${authBearer}`
    return headers
  }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants