guest@mukunda.com:/blog# ./cat 2023/dns-resolution-from-javascript.txt Name: DNS Resolution From Javascript Date: 1/13/23 I had an interesting problem today - resolving an SRV record from Javascript client-side. There's no native way for the browser to query a DNS server, so you have to get a little clever. A usual approach is to delegate the DNS resolution to an API endpoint on your webserver. However, in this case I'm developing a browser extension, so there isn't one known web server. Lucky for us, DNS over HTTP exists, and Google implements an easy API to use. To get a fairly reliable result, you can query dns.google over HTTP. https://developers.google.com/speed/public-dns/docs/doh Example request: https://dns.google/resolve?name=mukunda.com&type=a See https://developers.google.com/speed/public-dns/docs/doh/json for more info about the JSON API. Send the author a comment << Index