Heroku suggests to use NPM packages to handle forcing SSL for express apps. I've done this in the past without issue. In this case I'm using a react app and I cannot get any of the NPM packages to work. I've tried the following and more:
https://www.npmjs.com/package/force-ssl-heroku
https://www.npmjs.com/package/express-force-ssl
https://www.npmjs.com/package/force-secure-express
This solution taken from this post Why cannot I redirect my React app on Heroku from http to https? is the only thing I have been able to get to work.
<script>
var host = "www.URL.com" || "URL.com";
if ((host == window.location.host) && (window.location.protocol != "https:")){
window.location.protocol = "https";
}
</script>
Is this the best current solution for Heroku React apps trying to force HTTPS?
Tip: If you try this solution please look at notes on the solution in the link above.
Thanks!