Redirect to https in Node.js
amasad (2269)

If you want to make sure your replit site only serves https you can use this middleware.

You are viewing a single comment. View All
MrEconomical (2128)

I always put a script in the client-side to do that lol

nithilan4 (234)

@MrEconomical

if (window.location.protocol == "http:") 
window.location.protocol = "https:";

lmao

nithilan4 (234)

@TaylorLiang surprisingly yes but only for things like replit that can be http or https

MrEconomical (2128)

@TaylorLiang yes - I use

<script>window.location.href.match("https")||(window.location.href=window.location.href.replace("http","https"));</script>