Redirecting the Heroku “Open app” button to a custom domain

While looking for areas to improve on Cushion’s infra side, I realized a shortcoming with Heroku’s admin panel that I had begrudgingly put up with for the past six years.

In the pipeline section, each e…


This content originally appeared on Jonnie Hallman (@destroytoday) and was authored by Jonnie Hallman (@destroytoday)

While looking for areas to improve on Cushion’s infra side, I realized a shortcoming with Heroku’s admin panel that I had begrudgingly put up with for the past six years.

Heroku open app button

In the pipeline section, each environment has a handy “Open app” button, but this simply opens a tab with the herokuapp.com URL, so it’s not exactly useful for folks who have a custom domain for their app. Instead of blindly accepting this reality and continuing to lie to myself that there’s nothing I can do, I realized I could simply add a redirect:

get '/', host_name: /^[\w-]+\.herokuapp\.com/ do
  redirect 'https://mycoolapp.biz'
end

This works if you like to hard-code things, but Cushion also has a staging environment at a different, top secret URL, so I can’t (and shouldn’t) hard-code the redirect URL and call it a day. Instead, I can use an environment variable to change the app URL between environments:

get '/', host_name: /^[\w-]+\.herokuapp\.com/ do
  redirect ENV['APP_URL']
end

Now, when I click the “Open app” button on either the staging app or the production app in Heroku’s pipeline panel, I end up where I expected I’d be. Such an obvious solution, but I simply never took the time to make the change. In an ideal world, Heroku would have a setting to route that button to the custom domain you already have listed in your settings, but we can’t have everything.

Reply via email


This content originally appeared on Jonnie Hallman (@destroytoday) and was authored by Jonnie Hallman (@destroytoday)


Print Share Comment Cite Upload Translate Updates
APA

Jonnie Hallman (@destroytoday) | Sciencx (2020-06-10T20:42:00+00:00) Redirecting the Heroku “Open app” button to a custom domain. Retrieved from https://www.scien.cx/2020/06/10/redirecting-the-heroku-open-app-button-to-a-custom-domain/

MLA
" » Redirecting the Heroku “Open app” button to a custom domain." Jonnie Hallman (@destroytoday) | Sciencx - Wednesday June 10, 2020, https://www.scien.cx/2020/06/10/redirecting-the-heroku-open-app-button-to-a-custom-domain/
HARVARD
Jonnie Hallman (@destroytoday) | Sciencx Wednesday June 10, 2020 » Redirecting the Heroku “Open app” button to a custom domain., viewed ,<https://www.scien.cx/2020/06/10/redirecting-the-heroku-open-app-button-to-a-custom-domain/>
VANCOUVER
Jonnie Hallman (@destroytoday) | Sciencx - » Redirecting the Heroku “Open app” button to a custom domain. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2020/06/10/redirecting-the-heroku-open-app-button-to-a-custom-domain/
CHICAGO
" » Redirecting the Heroku “Open app” button to a custom domain." Jonnie Hallman (@destroytoday) | Sciencx - Accessed . https://www.scien.cx/2020/06/10/redirecting-the-heroku-open-app-button-to-a-custom-domain/
IEEE
" » Redirecting the Heroku “Open app” button to a custom domain." Jonnie Hallman (@destroytoday) | Sciencx [Online]. Available: https://www.scien.cx/2020/06/10/redirecting-the-heroku-open-app-button-to-a-custom-domain/. [Accessed: ]
rf:citation
» Redirecting the Heroku “Open app” button to a custom domain | Jonnie Hallman (@destroytoday) | Sciencx | https://www.scien.cx/2020/06/10/redirecting-the-heroku-open-app-button-to-a-custom-domain/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.