Skip to content

Use the fetch available in the environment instead of cross-fetch #389

@inian

Description

@inian

For cloudflare workers and deno where there is fetch available in the environment already, currently we need initialise the client like this

const supabase = createClient(
    "https://yyy.supabase.co",  "xxx", {
      fetch: fetch.bind(globalThis),
    }
  );

Instead we should use the following algorithm to get fetch

  • Use the custom fetch option when provided
  • Use the global fetch if available
  • else use cross-fetch

With Node implementing the fetch standard soon, fetch is a global we can reasonably assume the existence of in most envionments and only load cross-fetch as a polyfill. cross-fetch also assumes the presence of XMLHttpRequest which leads to a lot of errors.

Client libraries to update

  • storage-js
  • postgrest-js
  • realtime-js (doesn't use fetch)
  • gotrue-js

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions