cross-fetch icon indicating copy to clipboard operation
cross-fetch copied to clipboard

fix: use existing fetch if it exists, otherwise fallback to whatwg-fetch

Open ThisIsMissEm opened this issue 3 years ago • 1 comments

I'm not sure why the code was written the way it is, but it appears to be forcing the polyfill to be used even in environments where the Fetch API exists natively, which isn't intentional and causes the bugs described in #91, #78, and #69.

The original commit and PR don't describe why the behaviour was changed: https://github.com/lquixada/cross-fetch/commit/123b1a2ef13f279f444118398959fb3424abfca4

ThisIsMissEm avatar May 26 '22 19:05 ThisIsMissEm

This will need a build done on this branch, since you're committing the build artifacts to the repo too.

ThisIsMissEm avatar May 26 '22 19:05 ThisIsMissEm

Is there any update on the above PR @ThisIsMissEm @jpwilliams ?

firehudson avatar Feb 09 '23 09:02 firehudson

Is there any update on the above PR @ThisIsMissEm @jpwilliams ?

We're ditching cross-fetch for our own package that works for our use case better, it'll be released soon.

ThisIsMissEm avatar Feb 09 '23 15:02 ThisIsMissEm

Any updates here? This is blocking a lot of AI Provider's SDKs from working on Vercel and Cloudflare Workers.

jaredpalmer avatar Apr 17 '23 21:04 jaredpalmer

Any updates here? This is blocking a lot of AI Provider's SDKs from working on Vercel and Cloudflare Workers.

My former employer, Inrupt, has released a replacement called @inrupt/universal-fetch which is designed to use native fetch if it exists (doesn't polyfill for older browsers), but will use native node.js 18+ fetch, or uses undici in node.js 16 (same as the new native fetch) or finally node-fetch in node 14.

edit: I'm not sure if it's fetch detection will work 100% out of the box on Cloudflare Workers or Vercel Functions, but I think it should, and they'd probably appreciate patches if it doesn't work on those platforms.

Might be worth a look.

ThisIsMissEm avatar Apr 18 '23 00:04 ThisIsMissEm

hi @ThisIsMissEm. thanks for taking the time to work on this PR. I'm closing this in favor of #163 .

lquixada avatar May 07 '23 12:05 lquixada