Since your paths are the same no matter which domain, it is simple. Take the hostname from the query passed to the express route methods, and then do any search you need. Node does not care what a domain is, and as long as your domain has a CNAME for your subdomains, and user domains point to the same IP address as myappname.com, Node will respond to all requests in the same way.
For example, in your / someaction route:
app.get('/someaction', function(req,res) { hostName = req.header('host');
source share