Skip to content

Commit

Permalink
feat: pass global header bearer token as apikey to RealtimeClient (#699)
Browse files Browse the repository at this point in the history
  • Loading branch information
w3b6x9 authored Feb 1, 2023
1 parent 46b8d2d commit b55d386
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/SupabaseClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,9 +265,11 @@ export default class SupabaseClient<
}

private _initRealtimeClient(options: RealtimeClientOptions) {
const authHeader = options.headers?.Authorization
const authToken = authHeader?.startsWith('Bearer ') && authHeader.split(' ')[1]
return new RealtimeClient(this.realtimeUrl, {
...options,
params: { ...{ apikey: this.supabaseKey }, ...options?.params },
params: { ...{ apikey: authToken || this.supabaseKey }, ...options?.params },
})
}

Expand Down

0 comments on commit b55d386

Please sign in to comment.