How do I do fetch('https://localhost:8888') for a locally running HTTP server with a self-signed cert (fetch coming from undici)?
The trick is to use setGlobalDispatcher (getGlobalDispatcher can be used to grab the original one for later restoration).
import {
fetch,
setGlobalDispatcher,
Agent,
} from 'undici'
setGlobalDispatcher(new Agent({
connect: {
rejectUnauthorized: false
}
}))
fetch('https://localhost:8888').then(...)