You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My mistake, I typed the example out wrong rather than copying/pasting. The cert, key and ca parameters should be within a connect object. I've updated the earlier example.
Activity
alexwhitman commentedon Jul 31, 2023
You can do it but you have to install
undici.That would useful to not have to install
undiciseparately if it's bundled in the core anyway.ottob commentedon Jul 31, 2023
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.
ottob commentedon Jul 31, 2023
Will that workaround work? The type definition for fetch in native does not expose
dispatcheronRequestInit.alexwhitman commentedon Jul 31, 2023
It works, I've got code that uses it against a service requiring mTLS.
ottob commentedon Jul 31, 2023
Strange. Im using
"undici": "5.22.1"and cert and key are not available in theAgentoptions:Object literal may only specify known properties, and 'cert' does not exist in type 'Options'Also, are you sure you are using fetch from core and not importing it from undici?
import { fetch, Agent } from 'undici'alexwhitman commentedon Jul 31, 2023
My mistake, I typed the example out wrong rather than copying/pasting. The
cert,keyandcaparameters should be within aconnectobject. I've updated the earlier example.ottob commentedon Jul 31, 2023
Thanks, I got it to work now.
dispatcheris not defined in theRequestInittype for core fetch. But if I cast it withas anyit works.So if the undici
Agentwas exposed from core this would work out of the box. Lets hope this will happen.ottob commentedon Jul 31, 2023
And there already seems to be an issue for that: #47592
kchojhu commentedon May 28, 2024
Thanks for this post and it worked. Please include this soon to next minor versions of Next.js.
tjconcept commentedon Mar 23, 2025
For reference, I think Deno solved this more elegantly: https://docs.deno.com/api/deno/fetch
meakgoz commentedon Apr 24, 2025
Is there any news on this comment from @alexwhitman?