anges244
anges244

Reputation: 697

How to point a custom domain to a Heroku subdomain?

Is it possible to allow users to use their own custom domains to point to a specific Heroku subdomain? I'm using wildcard subdomains that allow my app to use abc.myapp.com URL's. Could a user add myuser.com and point to that? How can this be done?

Trying to add CNAME to point there returns Heroku | No such app messages and when I add the custom domain to the Heroku Dashboard it just points to the top level domain.

DETAILED STEPS:

CNAME mydomain.com ---> myapp.herokuapp.com -- works fine

CNAME anotherdomain.com ---> sub.mydomain.com -- not working

If I add anotherdomain.com to the Heroku dashboard then:

CNAME anotherdomain.com ---> sub.mydomain.com or mydomain.com -- works fine but opens the root domain mydomain.com in either cases

So I guess the only way to serve the proper subdomain is to handle it inside my app, so that anotherdomain.com in the db corresponds to sub.mydomain.com and serve the proper page.

Upvotes: 2

Views: 660

Answers (1)

Damien MATHIEU
Damien MATHIEU

Reputation: 32629

In your app's code, you need to configure that new domain to point to your app.
This is what you would manually be doing with the heroku domains:add command.

Using heroku's Platform API, you can perform this programmatically.

Upvotes: 3

Related Questions