node
node copied to clipboard
esm(network imports): expose `User-Agent` header
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. https://github.com/nodejs/node/blob/5e3d003113739672b4f56a0fa4e8109833461f3a/lib/internal/modules/esm/fetch_module.js#L47-L69
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
.
FYI we're considering replacing fetch_module with fetch