lquixada / cross-fetch

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

Use node-fetch options on-demand #117

Closed undergroundwires closed 1 year ago

undergroundwires commented 2 years ago

I use node.js successfully on client side, but on same project I'd also love to use cross-fetch using node-fetch options.

I would love to follow redirects, and it's not possible using WHATWG Fetch API but it's possible with node-fetch and follow option.

Reproduce in node:

  1. import fetch from 'cross-fetch';
  2. Call fetch with init argument that contains follow: 200 (node-fetch specific option)
  3. Node-fetch is called without follow: 200 option

I'm not sure if it's a bug report or feature request, but is there I way I can use it with options from node-fetch? I understand that the goal is to support WHATWG Fetch API, but should we strip down functionality that's already there? Or would you suggest any other solution for following redirects?

Thank you for maintaining this clean and magical library, I've seen using it successfully in privacy.sexy successfully and would love to continue doing it

lquixada commented 1 year ago

@undergroundwires thanks for opening this issue. As you mentioned, the purpose of cross-fetch is to serve as a proxy for different environment implementations of the Fetch API standard. There's no plan to add any kind of feature on this lib.

That being said, some possible alternatives would be:

  1. Implement the functionality on top of cross-fetch.
  2. Build and publish your own version of cross-fetch with that feature (and potentially others).
  3. Request this feature on the supported implementations (whatwg-fetch, nodejs)
  4. Propose a change in the Fetch API spec.

Thanks again for taking the time to report this issue!