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):
- Separate Marketing site from Webapp site (
www.website.com
andapp.website.com
) - Different entry points depending on type of users (
user.website.com
andclient.website.com
) - API subdomain (
api.myapp.com
) - SAAS multi-tenancy
Community Page
Last updated:
Last updated: