Skip to content

Commit

Permalink
fix: set apikey instead of append
Browse files Browse the repository at this point in the history
  • Loading branch information
alaister committed Jun 7, 2022
1 parent 5ff8055 commit 8dace6e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/lib/fetch.ts
Expand Up @@ -23,19 +23,19 @@ export const resolveHeadersConstructor = () => {
}

export const fetchWithAuth = (
supabaseAnonKey: string,
supabaseKey: string,
getAccessToken: () => Promise<string | null>,
customFetch?: Fetch
): Fetch => {
const fetch = resolveFetch(customFetch)
const HeadersConstructor = resolveHeadersConstructor()

return async (input, init) => {
const accessToken = (await getAccessToken()) ?? supabaseAnonKey
const accessToken = (await getAccessToken()) ?? supabaseKey
let headers = new HeadersConstructor(init?.headers)

if (!headers.has('apikey')) {
headers.append('apikey', supabaseAnonKey)
headers.set('apikey', supabaseKey)
}

if (!headers.has('Authorization')) {
Expand Down

0 comments on commit 8dace6e

Please sign in to comment.