Skip to content

Commit b55d386

Browse files
authored
feat: pass global header bearer token as apikey to RealtimeClient (#699)
1 parent 46b8d2d commit b55d386

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/SupabaseClient.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,9 +265,11 @@ export default class SupabaseClient<
265265
}
266266

267267
private _initRealtimeClient(options: RealtimeClientOptions) {
268+
const authHeader = options.headers?.Authorization
269+
const authToken = authHeader?.startsWith('Bearer ') && authHeader.split(' ')[1]
268270
return new RealtimeClient(this.realtimeUrl, {
269271
...options,
270-
params: { ...{ apikey: this.supabaseKey }, ...options?.params },
272+
params: { ...{ apikey: authToken || this.supabaseKey }, ...options?.params },
271273
})
272274
}
273275

0 commit comments

Comments
 (0)