undici
undici copied to clipboard
The DNS Interceptor is unable to retrieve the origin properly
Bug Description
In the code example below, I provide the URL twice: first, when creating the Client instance, and again as the origin in the request options. This redundancy is unnecessary. However, when using the DNS interceptor, omitting the URL from the request options will result in an error.
Reproducible By
import { Client, interceptors } from 'undici';
const { dns } = interceptors;
const client = new Client('https://jsonplaceholder.typicode.com/').compose(dns());
const response = await client.request({
origin: 'https://jsonplaceholder.typicode.com/', // Commenting this line will cause an error
method: 'GET',
path: '/posts/1',
headers: {
'Content-Type': 'application/json',
},
});
const data = await response.body.json();
console.log(data);
Expected Behavior
The DNS interceptor should be capable of retrieving the URL directly from the client.
Logs & Screenshots
Environment
Ubuntu 22.04 LTS, Node v22.15.1, npm v10.9.2 undici v7.10.0
See discussions here: #3957
Basically origin must be provided each time with Client (and Pool).