I'm trying to get my Node.js powered site to run on one instance serving multiple domains. I have my main domain, example.com
and then I have admin.example.com
and api.example.com
which all have different routes etc, I'm using Express.
So far I've added two A records for the subdomains, and also added two entries into /var/vhosts
on my CentOS box.
127.0.0.1 api.example.com
127.0.0.1 admin.example.com
127.0.0.1 example.com
I'm aware that Express has a express.vhost
method so I've already tried:
app.use(express.vhost('api.example.com', require('./lib/subdomains/api')))
app.use(express.vhost('admin.example.com', require('./lib/subdomains/admin')))
But that still only serves my main routes which is imported below. What am I missing?