expressjs / vhost

virtual domain hosting

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

vhost for multiple domain

hdriqi opened this issue · comments

commented

For example I have 3 domains called abc.com, def.com and ghi.com

I want the vhost to be able to serve *.abc.com, *.def.com and *.ghi.com, but I want to do it automatically means that the domains can be added dynamically.

Is there any way to do it?

commented

It turns out that I can use this:

const domain = ['abc.com', 'def.com']
domain.forEach((dom)=>{
	mainApp.use(vhost('*.' + dom, myapp))
})

Is this a good solution?

Hi @hdriqi yep, just use the middleware as many times as needed :) 👍