简体   繁体   中英

Can I use subdomains with my Heroku subdomain?

I have a node app which uses vhost to manage subdomains. So, on my localhost I have:

main.localhost
admin.localhost
api.localhost

In production I have:

main.example.com
admin.example.com
api.example.com

I have a staging system on Heroku too.

so what I want to be able to do is:

main.example.herokuapp.com
admin.example.herokuapp.com
api.example.herokuapp.com

That doesn't seem to work. Is there a way of achieving it, or do I need to create a separate domain and point my nameservers there?

Sure this is possible. But you'll need to do this via your main domain, since it appears Heroku doesn't support wildcard subdomains on the herokuapp.com domain. ( How to create a subsubdomain for an app on heroku: (eg sub.myapp.herokuapp.com) )

First, set a CNAME record for *.staging.example.com to point to example.herokuapp.com

Then tell Heroku to route your domain properly:

$ heroku domains:add *.staging.example.com

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM