When developing a web app locally I like to use addresses like app.localhost:8080 to access them. They work fine in Chrome but not in Safari. I guess this is because Chrome has special handling for the TLD and Safari uses the OS DNS resolver.
Is there a way to make macOS resolve all .localhost addresses to 127.0.0.1?
1 Answer
Yes, as the root you should edit your /etc/hosts file and add line(s) like
127.0.0.1 app.localhost
127.0.0.1 app2.localhostetc.
If it doesn't work immediately then restart browser/reboot.
Update:
I have no mac, but try 127.0.0.1 *.localhost. For my Linux it does NOT work, then the only way is to set up a DNS server on your box and configure 'localhost' zone on it.