How to point a custom domain to a Heroku subdomain?

吃可爱长大的小学妹 提交于 2020-05-17 04:02:33

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/37544183/how-to-point-a-custom-domain-to-a-heroku-subdomain

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!