From 400d82901ee89ce1277761ddbb45d48990ebd4ec Mon Sep 17 00:00:00 2001 From: jaeh Date: Sat, 13 Apr 2024 19:26:05 +0200 Subject: [PATCH] src/main.js: fix isLocal && isHttp if condition --- src/main.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main.js b/src/main.js index aeaccb0..2f00d08 100644 --- a/src/main.js +++ b/src/main.js @@ -6,7 +6,14 @@ /* * force glitch to use https */ -if (window.location.protocol === 'http:' && window.location.host !== 'localhost') { + +const { + hostname, + protocol +} = window.location; +const isLocal = hostname !== 'localhost' && hostname !== '127.0.0.1'; +const isHttp = protocol === 'http:'; +if (!isLocal && isHttp) { window.location.protocol = 'https:'; } const main = async () => {