-
Notifications
You must be signed in to change notification settings - Fork 32
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Currently, we fully mock node:dns
module since it depends on an OS feature however we could implement it using DNS-over-HTTPS.
async function resolveDomain(domain) {
const dohServer = process.env.UNENV_DOH_URL || 'https://cloudflare-dns.com/dns-query';
const url = `${dohServer}?name=${domain}&type=A`;
try {
const response = await fetch(url, {
headers: {
'Accept': 'application/dns-json'
}
});
if (!response.ok) {
throw new Error(`HTTP error! Status: ${response.status}`);
}
const { Answer = [] } = await response.json();
return Answer;
} catch (error) {
console.error('Error resolving domain:', error);
}
}
// Usage example
resolveDomain('example.com').then(data => console.log(data));
anbraten
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request