Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Revert "Merge pull request #175 from supabase/fix/supabase-node-fetch" #176

Merged
merged 1 commit into from
Aug 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
144 changes: 84 additions & 60 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"docs:json": "typedoc --json docs/v2/spec.json --entryPoints src/index.ts --entryPoints src/packages/* --excludePrivate --excludeExternals --excludeProtected"
},
"dependencies": {
"@supabase/node-fetch": "^2.6.13"
"cross-fetch": "^3.1.5"
},
"devDependencies": {
"@types/jest": "^26.0.13",
Expand Down
8 changes: 3 additions & 5 deletions src/lib/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,16 @@ export const resolveFetch = (customFetch?: Fetch): Fetch => {
if (customFetch) {
_fetch = customFetch
} else if (typeof fetch === 'undefined') {
_fetch = (...args) =>
import('@supabase/node-fetch' as any).then(({ default: fetch }) => fetch(...args))
_fetch = async (...args) => await (await import('cross-fetch')).fetch(...args)
} else {
_fetch = fetch
}
return (...args) => _fetch(...args)
}

export const resolveResponse = async (): Promise<typeof Response> => {
export const resolveResponse = async () => {
if (typeof Response === 'undefined') {
// @ts-ignore
return (await import('@supabase/node-fetch' as any)).Response
return (await import('cross-fetch')).Response
}

return Response
Expand Down
3 changes: 1 addition & 2 deletions test/storageFileApi.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import * as fs from 'fs'
import * as path from 'path'
import FormData from 'form-data'
import assert from 'assert'
// @ts-ignore
import fetch from '@supabase/node-fetch'
import fetch from 'cross-fetch'

// TODO: need to setup storage-api server for this test
const URL = 'http://localhost:8000/storage/v1'
Expand Down