Skip to content

Instantly share code, notes, and snippets.

@stokito
Created November 7, 2022 21:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stokito/1e520d348fbe3ccc4d87c2a43b5d7f90 to your computer and use it in GitHub Desktop.
Save stokito/1e520d348fbe3ccc4d87c2a43b5d7f90 to your computer and use it in GitHub Desktop.
JavaScript resolve DNS from browser
<html>
<script>
// https://stackoverflow.com/a/58299823/1049542
// https://developers.cloudflare.com/1.1.1.1/encryption/dns-over-https/make-api-requests/dns-json/
// var dnsQ = fetch('https://dns.google/resolve?name=stokito.com&type=A',
var dnsQ = fetch('https://cloudflare-dns.com/dns-query?name=stokito.com&type=A',
{
headers: {
'Accept': 'application/dns-json'
}
})
dnsQ.then((response) => {
var l = response.json()
console.log(l)
});
</script>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment