What is the problem this feature will solve?
We're building a registry server to serve our JavaScript packages in a variety of runtimes -- Node.js, Deno and the browser. Both the browser and Deno include a User-Agent header, but Node doesn't.
What is the feature you are proposing to solve the problem?
I propose altering the GET functions to include the user-agent header.
|
let HTTPSAgent; |
|
function HTTPSGet(url, opts) { |
|
const https = require('https'); // [1] |
|
HTTPSAgent ??= new https.Agent({ // [2] |
|
keepAlive: true, |
|
}); |
|
return https.get(url, { |
|
agent: HTTPSAgent, |
|
...opts, |
|
}); |
|
} |
|
|
|
let HTTPAgent; |
|
function HTTPGet(url, opts) { |
|
const http = require('http'); // [1] |
|
HTTPAgent ??= new http.Agent({ // [2] |
|
keepAlive: true, |
|
}); |
|
return http.get(url, { |
|
agent: HTTPAgent, |
|
...opts, |
|
}); |
|
} |
However, this poses some security concerns. Should it be exposed by default? Should there be another flag?
node --experimental-network-imports --experimental-network-imports-expose-ua ./foo.mjs.
What is the problem this feature will solve?
We're building a registry server to serve our JavaScript packages in a variety of runtimes -- Node.js, Deno and the browser. Both the browser and Deno include a
User-Agentheader, but Node doesn't.What is the feature you are proposing to solve the problem?
I propose altering the GET functions to include the user-agent header.
node/lib/internal/modules/esm/fetch_module.js
Lines 47 to 69 in 5e3d003
However, this poses some security concerns. Should it be exposed by default? Should there be another flag?
node --experimental-network-imports --experimental-network-imports-expose-ua ./foo.mjs.