How can I create subdomains for all my users?

Issue

You'd like to create custom subdomains for each of your users, like username.somecoolsite.com.

Resolution

We expect that most customers requesting a limit increase will be adding and managing domains programmatically using the Heroku API. However, adding and managing domains for an app can also be done within the "Settings" tab of the app's Heroku Dashboard.

Request a custom domain limit increase

There is currently a limit of 1,000 domains per app. This limit can be raised by the Heroku Support team if you submit a support ticket requesting an increase. Please provide details about your use case and suggest a new limit in the ticket.

Make use of Heroku's Platform API

We offer several Domain endpoints which make managing an app's domains easy to do programmatically. You will likely need to embed some domain-management logic into your app's code, perhaps something like this:

  1. Get a list of all the custom domains currently in use for the app using the Domain List endpoint.

  2. If the new custom domain to be added is not in this list, use the Domain Create endpoint to add it to the app. You will need to handle the case where the domain to be added is already in use.

  3. Your customers will need to update their DNS records to point to the new DNS targets generated by Heroku. You will need to provide your customers with these DNS targets and they will need to make any necessary adjustments in their DNS provider's dashboard. Please note that some DNS providers do not support ALIAS/ANAME records, which means that some of your customers may need to switch DNS providers if they want to use custom root domains with your service. You can read more about this here: https://help.heroku.com/NH44MODG/my-root-domain-isn-t-working-what-s-wrong

  4. If a user cancels their membership with your SaaS product, you can use the Domain Delete endpoint to remove their custom subdomain.

Special notes for SSL certificates

Ask on Stack Overflow

Engage with a community of passionate experts to get the answers you need

Ask on Stack Overflow

Heroku Support

Create a support ticket and our support experts will get back to you

Contact Heroku Support