lquixada / cross-fetch

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

Is user-agent supported? #65

Closed dandv closed 4 years ago

dandv commented 4 years ago

There's a long discussion at https://github.com/whatwg/fetch/issues/37 about user-agent, which apparently is no longer forbidden.

Is that header still ignored by cross-fetch? The following sent a user agent of node-fetch/1.0 (+https://github.com/bitinn/node-fetch).

fetch(url, {
    headers: {
      'User-Agent': 'Mozilla/5.0 (Linux; Android 10) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.106 Mobile Safari/537.36',  // Chrome Android, to maybe get a slimmer page version
    },
  })
lquixada commented 4 years ago

thanks for the issue report! cross-fetch is just a proxy for whatwg-fetch in a browser and node-fetch in Node. So it will honor whatever those libs allow. If you've got the node-fetch/1.0 user agent, node-fetch is being used, not whatwg-fetch.

dandv commented 4 years ago

Right! Thanks for the clarification :)