I have an angular application that currently handles tenants(customers) using our software to have their own online store load up based on query params. So https://my-site.com
is the main domain. Let’s say a user signs up for our app. They will have a url https://my-site.com/storeId=someId
which will route them to their store.
I want to change it so that when the user signs up, a subdomain is created https://subdomain.my-site.com
which redirects to https://my-site.com/storeId=someId
and loads up their store.
The application backend is NodeJs and Express and both the frontend and backend are deployed to heroku. The heroku app also has a custom domain.
Is there a way I can programatically have it so that the subdomain is automatically added to heroku and I can use an express or some middleware route or something similar to detect the subdomain and process the redirect.
There are very few posts I found about this and the few that are there are not useful or point to heroku documents which also don’t fully resolve my question. Some posts I looked at are:
Subdomain setup for Heroku
Dynamically creating subdomains on Heroku with nodeJS?
Subdomain alias in nginx and nodejs/express
shahzib sarfraz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.