Subdomain routing (Express)

It would be great if the routing for nodejs projects could take into account the subdomain.

So a route for / could be treated differently depending if the entry point is domain.com/ or sub.domain.com/

I believe Express provides this info in req.subdomains

req.subdomains

An array of subdomains in the domain name of the request.

// Host: "tobi.ferrets.example.com"
console.dir(req.subdomains)
// => ['ferrets', 'tobi']

There is also a middleware for this for inspiration or usage:

From a UI perspective I think with a new field in the route where you can enter the subdomain if any would be enough. And when viewing the list of routes a tag next to the route with the subdomain string.

Use cases(among others):

Community Page
Last updated: