Is express.vhost
able to support a wildcard to catch all traffic of one specific domain? I'm looking for every subdomain (www.example.com, xyz.example.com) and the TLD itself (example.com).
Asked
Active
Viewed 1,285 times
2

RienNeVaPlu͢s
- 7,442
- 6
- 43
- 77
1 Answers
9
Yes, express.vhost
supports wildcards since late 2010 when CoolAJ86 asked for it on GGroups:
// Will this work?
connect.vhost("*.example.com", function (req, res) {});
Well, it does now. But it's only receiving all subdomains, not the TLD itself.
Since you, great questioner (my earlier and maybe future self) are trying to catch everything related to the domain, its subdomains and their cats, you should not use two different routes simply out of desperation.
Just remove the first dot, it's not that hard, idiot.
connect.vhost("*example.com", function (req, res) {});

RienNeVaPlu͢s
- 7,442
- 6
- 43
- 77
-
8"Just remove the first dot, it's not that hard, idiot." - I thought you were being a bit of a dick to the OP, and then I realized YOU were the OP. +1 – codephobia Feb 26 '14 at 01:39
-
1Wouldn't that also match otherexample.com, causing potential security issues? Perhaps doing two vhosts for *.example.com and example.com would be better? – gkoberger Mar 10 '14 at 21:55
-
1@gkoberger It requires some knowledge about the host, but it seems like it would be possible to set up an A record for "iheartcatsexample.com" and have it point to this server's IP. Although all it does is serve his content from another domain. – Pier-Luc Gendreau Dec 04 '14 at 18:08