Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 685
Description
What is the problem this feature will solve?
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:
- Node.js
node node.mjsprints: undici:
// node.mjsimport{createServer}from'http'constserver=createServer((req,res)=>{console.log(req.headers['user-agent'])res.end()}).listen(3000)awaitfetch('http://localhost:3000')server.close()process.exit(0)- Bun
bun bun.jsprints: Bun/1.0.2:
// bun.jsconstserver=Bun.serve({port: 3000,fetch: (req)=>console.log(req.headers.get('user-agent')),})awaitfetch('http://localhost:3000')server.stop()- Deno
deno run --allow-net deno.jsprints: Deno/1.37.1:
// deno.jsDeno.serve({port: 3000},(request)=>{console.log(request.headers.get('user-agent'))returnnewResponse()})awaitfetch('http://localhost:3000')Deno.exit(0)What is the feature you are proposing to solve the problem?
I propose that the default user agent in Node.js changes to the format used by Deno, and Bun for consistency.
Example: Node/18.18.0
What alternatives have you considered?
Related: nodejs/node#43852nodejs/node#43851