Use JS to change the URL protocol from http to https.
Just add a script tag in your head pointing the file, you can use the jsdelivr CDN.
<script src="https://cdn.jsdelivr.net/npm/protocolredirect@2.1.0"></script>When the file runs, it checks if you are in http, if not, It will redirect you to the same page, but in https. Don't worry, if you are in localhost or 127.0.0.1 this will not do anything.