Created
March 15, 2023 20:52
-
-
Save RafaelGSS/5c27d92b6c85017791d73562387af347 to your computer and use it in GitHub Desktop.
Example custom connect fetch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { setGlobalDispatcher, Agent } = require('undici') | |
setGlobalDispatcher( | |
new Agent({ | |
connect: (opts) => { | |
console.log('Called with', opts) | |
// implement custom dns lookup | |
} | |
}) | |
) | |
fetch('https://example.com') | |
// ➜ test node index.js | |
//Called with { | |
// host: 'example.com', | |
// hostname: 'example.com', | |
// protocol: 'https:', | |
// port: '', | |
// servername: null, | |
// localAddress: null | |
//} | |
// |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment