mirror of
https://github.com/skidoodle/hostinfo
synced 2026-04-28 17:47:36 +02:00
fix lookup
This commit is contained in:
+5
-1
@@ -1,13 +1,17 @@
|
||||
export const DnsService = {
|
||||
async resolve(hostname: string): Promise<string | null> {
|
||||
try {
|
||||
const controller = new AbortController();
|
||||
const timeout = setTimeout(() => controller.abort(), 5000);
|
||||
const response = await fetch(
|
||||
`https://cloudflare-dns.com/dns-query?name=${hostname}&type=A`,
|
||||
{
|
||||
headers: { accept: 'application/dns-json' },
|
||||
credentials: 'omit'
|
||||
credentials: 'omit',
|
||||
signal: controller.signal,
|
||||
}
|
||||
);
|
||||
clearTimeout(timeout);
|
||||
|
||||
if (!response.ok) return null;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user