Posts

Showing posts with the label Subdomains localhost

Dnsmasq - wildcard subdomains on localhost

Image
I' m writing a multi-tenant web application where admin users create subdomains for each client. Subdomain is how the app knows which client to use for branding. But how the hell can I test something like this locally on a Mac? If you’re in the same boat or just tired of polluting your  /etc/hosts  file, it’s time to setup Dnsmasq. In this article, we’ll setup your Mac to answer all requests for a single top-level domain (TLD), in this case,  .test .  So  myproject.test  and any domain ending in  .test  will all be directed to your local machine. Keep in mind this process is valid as of macOS 12.0.1 Monterey. First, make sure you have  Homebrew  installed.  That process is well documented so I won’t go into it here.  I will, however, remind you  brew  veterans to update your installation and packages. brew update && brew upgrade Now, install Dnsmasq. brew install dnsmasq Now modify the config file at  /us...