Skip to content
Sign upLog in
← Back to Community
Force HTTPS
Profile icon
hacker
has Hacker Plan
eco27

Is there any way to force HTTPS on a website made with HTML / CSS / JS on repl? Having users connect on HTTP is pretty annoying sometimes

Answered by Vandesm14 [earned 5 cycles]
View Answer
Voters
Profile icon
leemlam
Profile icon
ArthurWu
Profile icon
GaussInTheHauss
Profile icon
AtticusKuhn
Profile icon
BubbleNugget
Profile icon
eco27
Comments
hotnewtop
Profile icon
Vandesm14

A way of doing this, on clientside, is to run this code at the beginning:

if (!window.location.href.match('https')) { window.location.href = window.location.href.replace('http', 'https'); }

But note it's not very efficient and can sometimes cause errors if https is not available.