File tree Expand file tree Collapse file tree 2 files changed +5
-3
lines changed Expand file tree Collapse file tree 2 files changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -100,7 +100,7 @@ export default class SupabaseClient<
100
100
this . headers ,
101
101
settings . global . fetch
102
102
)
103
- this . fetch = fetchWithAuth ( supabaseKey , this . _getAccessToken . bind ( this ) )
103
+ this . fetch = fetchWithAuth ( supabaseKey , this . _getAccessToken . bind ( this ) , settings . global . fetch )
104
104
105
105
this . realtime = this . _initRealtimeClient ( { headers : this . headers , ...settings . realtime } )
106
106
this . rest = new PostgrestClient ( `${ _supabaseUrl } /rest/v1` , {
Original file line number Diff line number Diff line change @@ -2,9 +2,11 @@ type Fetch = typeof fetch
2
2
3
3
export const fetchWithAuth = (
4
4
supabaseKey : string ,
5
- getAccessToken : ( ) => Promise < string | null >
5
+ getAccessToken : ( ) => Promise < string | null > ,
6
+ customFetch ?: Fetch
6
7
) : Fetch => {
7
8
return async ( input , init ) => {
9
+ const fetch_ = customFetch ?? fetch
8
10
const accessToken = ( await getAccessToken ( ) ) ?? supabaseKey
9
11
let headers = new Headers ( init ?. headers )
10
12
@@ -16,6 +18,6 @@ export const fetchWithAuth = (
16
18
headers . set ( 'Authorization' , `Bearer ${ accessToken } ` )
17
19
}
18
20
19
- return fetch ( input , { ...init , headers } )
21
+ return fetch_ ( input , { ...init , headers } )
20
22
}
21
23
}
You can’t perform that action at this time.
0 commit comments