How to create a subsubdomain for an app on heroku:

2019-01-23 05:58发布

问题:

I am running a multi tenant app that uses subdomains for tenants on Heroku. In production I have a domain where subdomains point to my heroku app. (This all works fine)

For staging, I'd like to test without creating another domain. Since my app uses the first subdomain it sees to find the current tenant, I was hoping to use a url like: tenant.myapp.herokuapp.com. However, this is not working (heroku returns a 'no such app' error.)

I've found this post from 2 years ago that says it should be possible, but I don't see this add-on/option anymore in the referenced documentation.

I have tried adding the subdomains as a wildcard in heroku by running

heroku domains:add *.myapp.herokuapp.com

but this returned

! Trying to hijack another Heroku app? Tsk, tsk.

Does anyone know if this can still be accomplished and if so, how?

note: I'm currently using my staging environment by CNAMING *.staging.myapp.com to myapp.heroku.com, but would like to clean that up.

回答1:

Here's how you use subdomains with heroku

Full Details here

Custom subdomains

For each custom subdomain you want to attach to your app (for example, www.example.com), use the domains:add command from the Heroku CLI:

$ heroku domains:add www.example.com`
Adding www.example.com to example... done

This is no longer valid: "Subdomains are currently not possible on heroku"