lquixada / cross-fetch

Universal WHATWG Fetch API for Node, Browsers and React Native.
MIT License
1.67k stars 104 forks source link

When init.headers are native Headers, they won't get send #79

Closed FokkeZB closed 3 years ago

FokkeZB commented 3 years ago

When options.headers already is a native Headers object, this will lead to an empty this.headers:

https://github.com/lquixada/cross-fetch/blob/22578271d864d24074c455b8a473b46898542f0f/dist/browser-ponyfill.js#L346-L348

This is because the instanceof check here is done against the polyfil:

https://github.com/lquixada/cross-fetch/blob/22578271d864d24074c455b8a473b46898542f0f/dist/browser-ponyfill.js#L93-L96

We should either not override Headers if it already exists, or keep a reference to the original and include it in the instanceof check as well.

lquixada commented 3 years ago

hey @FokkeZB ! Thanks for reporting that. cross-fetch is just a proxy for node-fetch on node environment and whatwg-fetch on browsers. The issue you're referring to is on the whatwg-fetch side. Please double check if this also happens on https://github.com/github/fetch/.

FokkeZB commented 3 years ago

Hey @lquixada - this is indeed happening there as well:

Sandbox: https://codesandbox.io/s/determined-cdn-7k3gx?file=/src/index.js Live: https://7k3gx.csb.app/

lquixada commented 3 years ago

Hopefully they will handle this issue! Closing this one.

FokkeZB commented 3 years ago

Hope so! Reported at https://github.com/github/fetch/issues/860