Skip to content

Commit a4fd29d

Browse files
committed
revert customFetch
1 parent 9a8ad62 commit a4fd29d

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/SupabaseClient.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ export default class SupabaseClient<
100100
this.headers,
101101
settings.global.fetch
102102
)
103-
this.fetch = fetchWithAuth(supabaseKey, this._getAccessToken.bind(this))
103+
this.fetch = fetchWithAuth(supabaseKey, this._getAccessToken.bind(this), settings.global.fetch)
104104

105105
this.realtime = this._initRealtimeClient({ headers: this.headers, ...settings.realtime })
106106
this.rest = new PostgrestClient(`${_supabaseUrl}/rest/v1`, {

src/lib/fetch.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@ type Fetch = typeof fetch
22

33
export const fetchWithAuth = (
44
supabaseKey: string,
5-
getAccessToken: () => Promise<string | null>
5+
getAccessToken: () => Promise<string | null>,
6+
customFetch?: Fetch
67
): Fetch => {
78
return async (input, init) => {
9+
const fetch_ = customFetch ?? fetch
810
const accessToken = (await getAccessToken()) ?? supabaseKey
911
let headers = new Headers(init?.headers)
1012

@@ -16,6 +18,6 @@ export const fetchWithAuth = (
1618
headers.set('Authorization', `Bearer ${accessToken}`)
1719
}
1820

19-
return fetch(input, { ...init, headers })
21+
return fetch_(input, { ...init, headers })
2022
}
2123
}

0 commit comments

Comments
 (0)