-
-
Notifications
You must be signed in to change notification settings - Fork 664
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
This would solve...
In some otherwise trivial cases for fetch()
a custom, one-purpose agent is required to manage a request, e.g. in order to check a server's identity manually or to disregard that verification completely (self-signed certificates come to mind). Current approach, from what I've seen, requires passing a set of TLS options to a dispatcher explicitly, then using said dispatcher to invoke a request - maybe it's just me, but I feel this could be simplified.
The implementation should look like...
Using https.Agent
as an example:
import https from 'node:https';
const result = await fetch("https://example.com", {
(...)
agent: new https.Agent({
rejectUnauthorized: false,
}),
});
(...)
I have also considered...
Some parameters can be set via alternative means; environment variables come to mind:
process.env.NODE_TLS_REJECT_UNAUTHORIZED = 0;
process.env.NODE_EXTRA_CA_CERTS = ...;
However, I don't think applying this to every request is a good idea (same goes for any global agents).
Additional context
Implementations in similar projects:
Possibly relevant issues:
ahmedelq and talentlessguy
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request