Search code examples
node.jsexpressherokucloudflarenamecheap

Create A Subdomain Per User


I want to create a subdomain per user, eg: "bumpy.example.com". How do I do this? I'm using express, Heroku, Cloudflare, and Namecheap (domain provider, but Cloudflare is my nameserver). If you could provide steps that would be great.


Solution

  • So a few steps:

    1. You need a custom domain name (ie: example.com).
    2. Then you need a wildcard SSL for that domain name: (ie: *.example.com).
    3. Then you need to setup your routing system to make use of that domain name, sadly not familiar with express, so this is as much as I can help you, but the gist is that you store the subdomain value for each user.

    Also searching online for things like Express <name of the database you use> Multi-tenancy might help in terms of finding libraries to handle the backend logic.