You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, Node.js uses undici for its fetch implementation. This sets undici as the default user agent.
From Node.js' perspective, undici is an implementation detail and so it should have its own user agent header.
For context at Next.js, we stopped polyfilling globalThis.fetch in favor of the platform-provided alternative (previously using node-fetch), and started getting reports where users did not know where the requests with the undici user agent were coming from.
I've tested the current behavior in different runtimes, here is Node.js, Bun and Deno for comparison:
I'm 👍 for this change. Undici should maybe be dynamic and still return undici when called directly from Undici, but then when in Node.js it uses Node/<Version>. Not sure how to implement that exactly off the top of my head though.
Activity
Ethan-Arrowood commentedon Oct 2, 2023
I'm 👍 for this change. Undici should maybe be dynamic and still return
undiciwhen called directly from Undici, but then when in Node.js it usesNode/<Version>. Not sure how to implement that exactly off the top of my head though.mscdex commentedon Oct 2, 2023
I'd rather have User-Agent be opt-in, but at the very least it should not contain version information.
Ethan-Arrowood commentedon Oct 2, 2023
What would the opt-in mechanism be?
I also agree -- for lower level http apis. Fetch is high-enough level that I believe its okay to be making default decisions like user-agent header.
KhafraDev commentedon Oct 2, 2023
spec-wise we have to add a user-agent header.
balazsorban44 commentedon Oct 2, 2023
Keep in mind, it's already there, its value is just confusing.
What would be the argument for not adding a version number? Most clients I can think of has one. 🤔
mscdex commentedon Oct 2, 2023
At least for security reasons.
KhafraDev commentedon Oct 2, 2023
Keep in mind that browsers are actually removing info from the user agent headers, for the reason mentioned above. https://developer.chrome.com/blog/user-agent-reduction-android-model-and-version/
[-]Change default "user-agent" to `Node/version`[/-][+]Change default "user-agent" from `undici`[/+]benjamingr commentedon Oct 3, 2023
I'm +1 to changing it to simply
"node"or something similarEthan-Arrowood commentedon Oct 3, 2023
Based on the way browsers are going let's settle on switching it to
"node"or"nodejs". Since that is significantly more recognizable than"undici"KhafraDev commentedon Oct 3, 2023
I don't have an opinion, anything is fine with me
mcollina commentedon Oct 4, 2023
I would rather not have one, but the spec mandate us.
nodeis better thanundicibecause it's 3 bytes less.Who wants to do the honors?
Ethan-Arrowood commentedon Oct 4, 2023
On it 🚀