title: Node.js - subdomain per user + allowing custom domain
body: <p>Using Node.js/Express I have a REST API with multiple isomorphic/universal applications which consume this API.</p>
  
  <p>I would like to allow users to have their own subdomain and this to happen dynamically as they sign up.</p>
  
  <p>From what I've researched the best way to do this is to point a wildcard record to the isomorphic/universal application servers and have some logic there which interprets requests looking for a subdomain and serves up the appropriate pages. This I assume needs to sit in front of the application and happen for every request to the server.</p>
  
  <p><strong>Would this be the best way to approach this problem? Is there an alternative way?</strong></p>
  
  <p><strong>Are there going to be any potential issues with scalability?</strong></p>
  
  <p>I would then like to allow users to have a custom domain. Tumblr and other services provide a similar feature where they allow you to point a CNAME record to the users subdomain. I have been unable to find much information on how this works.</p>
  
  <p><strong>What is the best way to allow users to use a custom domain for their area within an application?</strong></p>