DEV Community

loading...

Discussion on: How to create sub-domain automatically when users register on my SaaS application ?

Collapse
matthew_collison profile image
Matthew Collison

You wouldn't create the subdomain on the fly, you'd simply use a wildcard subdomain (*.yourwebsite.tld) and point that to your webserver.

Depending on what backend framework you are using, you'd need to ingest the subdomain as a parameter and use the value from that to find the user (or throw a 404, of course)

Hope that helps!

Collapse
simo97 profile image
ADONIS SIMO Author

oww.... that's interesting... i only knew about SSL wildcard certificat... this is sooo cool. Thank it solve my problem, am working with a NGINX + Gunicorn + Django Stack.. i can handle the domain name ingestion without problem... thank you for this.

Collapse
matthew_collison profile image
Matthew Collison

Super welcome - glad it helped!

Collapse
d3sandoval profile image
Daniel Sandoval

Yup! This is essentially what anymessage does to generate the team subdomains. Feel free to checkout the code, if you'd like a node.js example: github.com/d3sandoval/anymessage

Collapse
kosadaz profile image
Kosadaz

Hi Matthew,

Better to have single VM and single db running for each tenant? Or multitenant single db if that the case?

ie. Slack use subdomain with single db or multitenant db?