How do I redirect http to https on adonis

I’m hosting my app on heroku. I don’t know the path to the Let’s Encrypt SSL cert and key.

How do I redirect my site request to https?

As per my understanding, it will auto changed to https when deployed to heroku

1 Like

The site is already deployed to heroku. I upgraded to a paid dyno and have the heroku Let’s Encrypt certificate.
I don’t know the path to the cert, so the guide here doesn’t work.

https://adonisjs.com/recipes/4.1/using-https

Not sure how cert management works in Heroku but here seems to be some guide: https://devcenter.heroku.com/articles/understanding-ssl-on-heroku

Also read from somewhere, that you have to redirect from HTTP to HTTPS yourself in application layer. Adonis middleware is perfect for it https://adonisjs.com/docs/4.1/middleware

In middleware you can check if request is HTTP or HTTPS and then redirect from HTTP to HTTPS when required

2 Likes

I did that but got the following error:

site redirected you too many times.

ERR_TOO_MANY_REDIRECTS