fetch icon indicating copy to clipboard operation
fetch copied to clipboard

Domains defined in the /etc/hosts file do not resolve

Open Kethatril opened this issue 2 years ago • 0 comments

I am using Craft Nitro (https://getnitro.sh/) for local CMS development and connecting to the api using @vercel/fetch. Nitro provides URL's that look like https://testcms.nitro and updates the /ect/hosts file with that domain. However these domains do not resolve using @vercel/vetch

It looks like this is happening because https://github.com/vercel/dns-cached-resolve is using dns.resolve4/dns.resolve6 both of which ignore the hosts file. Looking into the node DNS documentation it looks like dns.lookup uses the system DNS lookup which does look at /etc/hosts however there are performance implications when using it (https://nodejs.org/api/dns.html#implementation-considerations)

https://github.com/vercel/dns-cached-resolve special cases localhost, but It might be a good idea to allow a fallback to dns.lookup when dns.resolve fails to allow other domains defined in /etc/hosts to work. This could be an option set when setting up @vercel/fetch and it would allow enabling / disabling this behaviour depending on environment.

Kethatril avatar Nov 23 '21 00:11 Kethatril