title: How to set up local subdomains for Node.js app
body: <p>I am running an express app on node.js. The app uses the <a href="https://www.npmjs.org/package/express-subdomain" rel="noreferrer">express-subdomain module</a> to help handle routes for two different subdomains (sub1.example.com and sub2.example.com). I'm hosting the app on AWS Elastic Beanstalk. In my production environment, everything works great. But on my local machine, I cannot get this to work. I tried adding the subdomains to my host file <code>127.0.0.1 localhost sub1.localhost sub2.localhost</code>. Although that allows me to prepend a subdomain to localhost, the module doesn't recognize this as a valid subdomain, and therefor searches for subdomain routes in my root routes.</p>
  
  <p>In main.js:</p>
  
  <pre><code>var routes = require('./routes/index')(passport);
  var sub1_routes = require('./routes/sub1')(passport);
  var sub2_routes = require('./routes/sub2')(passport);
  
  app.use(subdomain('sub1', sub1_routes));
  app.use(subdomain('sub2', sub1_routes));
  app.use('/', routes);
  </code></pre>
  
  <p>I need to be able to handle this locally. It takes to much time to push a small change to AWS test, iterate, etc.</p>