I am trying to run my Node.js website to run on a single instance serving multiple domains. I have my main domain example.com , and then I have admin.example.com and api.example.com , which have all different routes, etc. I am using Express.
So far, I have added two A entries for subdomains, and also added two entries to /var/vhosts in my CentOS field.
127.0.0.1 api.example.com 127.0.0.1 admin.example.com 127.0.0.1 example.com
I know that Express has a method express.vhost , so I've tried:
app.use(express.vhost('api.example.com', require('./lib/subdomains/api'))) app.use(express.vhost('admin.example.com', require('./lib/subdomains/admin')))
But it still only serves my main routes, which are imported below. What am I missing?
source share