14

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.

HectorMalot
  • 1,120
  • 1
  • 6
  • 13

1 Answers1

18

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"

Dheeraj Bhaskar
  • 18,633
  • 9
  • 63
  • 66
Eric Fode
  • 3,667
  • 2
  • 24
  • 29
  • Do you have a source for this? – elsurudo May 02 '13 at 13:04
  • 2
    Since this is a bit old, any chances that they are possible nowadays? In the near future? Cheers! – davegson Jan 03 '14 at 21:32
  • Nope, and there are no plans to make it so :(. The prevailing belief at the moment is the best way to do this is to use your own DNS provider. It is also a rather bad practice use a raw heroku domain in production. – Eric Fode Jan 09 '14 at 21:18
  • In my case it's more that I need a staging app. Looks like I will have to buy a new domain though just to have that work. :( – Askdesigners Aug 16 '14 at 14:56
  • 5
    What's the current state of the world for subdomains on Heroku? – srt32 Sep 17 '15 at 19:48
  • do you think it would be possible to spoof it via a custom domain name and checking the response object if it has api in it? http://guides.rubyonrails.org/action_controller_overview.html#the-request-object and to then route to the appropriate controller accordingly? – BenKoshy Jan 14 '17 at 04:09
  • 1
    This answer is no longer accurate. Please see the Heroku docs: https://devcenter.heroku.com/articles/custom-domains#add-a-wildcard-domain – rdegges Jan 17 '17 at 16:51