-
Notifications
You must be signed in to change notification settings - Fork 29.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Native fetch client certificate support #48977
Comments
You can do it but you have to install const { Agent } = require('undici');
fetch(url, {
dispatcher: new Agent({
connect: {
cert: cert,
key: key,
ca: ca
}
})
});
That would useful to not have to install |
Thanks for the workaround.
Yes, that would be very nice. The point of using the native version is to not have to depend on external libraries. |
Will that workaround work? The type definition for fetch in native does not expose |
It works, I've got code that uses it against a service requiring mTLS. |
Strange. Im using
Also, are you sure you are using fetch from core and not importing it from undici?
|
My mistake, I typed the example out wrong rather than copying/pasting. The |
Thanks, I got it to work now. So if the undici |
And there already seems to be an issue for that: #47592 |
Thanks for this post and it worked. Please include this soon to next minor versions of Next.js. |
What is the problem this feature will solve?
I could not find a way to make a TLS request with a client certificate (mutual tls) with the new native fetch client.
With node-fetch I could use an https.Agent:
But the agent option is not available in the api:
Object literal may only specify known properties, and 'agent' does not exist in type 'RequestInit'
Is there a way of doing that that I am missing?
What is the feature you are proposing to solve the problem?
I read that the new client is based on undici and I found their docs for this here:
https://undici.nodejs.org/#/docs/best-practices/client-certificate
Could the undici Client be exposed from node?
What alternatives have you considered?
No response
The text was updated successfully, but these errors were encountered: