✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
🏦 Standard & Poor's chooses Dash Enterprise for ESG analysis. Learn why, sign up for the June 23 Webinar here!

Force HTTPS with Dash for R App

I am hosting a Dash for R web app on a Heroku Hobby Dyno using a custom domain with automatic SSL/TLS enabled (i.e., when you explicitly navigate to https://examplewebsite.org, the connection is secure.

However, I would like to redirect from http://examplewebsite.org to HTTPS (i.e., force the site to use SSL/TLS). I have read the Heroku documentation which:

  1. Indicates that redirects must be performed at the application level - I must code the redirect logic into my Dash app.

  2. Recommends the use of GoogleCloudPlatform/flask-talisman for Flask apps in Python. However, I am using Dash for R, regarding which the documentation provides no recommendations. Even if I had the R-equivalent of Talisman installed, I am not sure how to explicitly access the Flask app object in Dash for R to attempt to apply it.

I have not been able to find a solution to this issue and kindly request your assistance. Thank you.

Although I have no idea how dash for R works. I assume you can use a reverse proxy in front of your R application. Search around for how to uses nginx as a reverse proxy for wsgi python apps, it should be strait forward to translate that to R. Bundling the whole thing into a docker container would make deployment simple too. With nginx, you can redirect all http requests to https no problem.