How to force HTTPS with create-react-app on heroku

Viewed 116

I'm running a very basic react app on Heroku and would like to force https on the production server, while still running localhost on https. I cannot for the life of me figure out how to do this on Heroku.

SSL and domain has been setup and works fine when I manually enter https:// before the domain. But if I manually type http:// this also works.

How do I redirect all http traffic to https for my react app on Heroko. I would like this to happen:

  • localhost:3000 still works in development
  • https is forced on production domain
  • create-react-app still runs without being "ejected"

Typically I'd set this up on the DNS, but Heroku only allows for a CNAME setup, so I cannot do this on the DNS level. I assume a custom server is required like express, but I cannot find any documentation on how to do this for production while stille working normally in development/localhost.

0 Answers
Related