From 426656e5e3f129f26a7dde17d2f0efee0519d001 Mon Sep 17 00:00:00 2001 From: Guangcong Luo Date: Thu, 16 Nov 2023 00:01:30 +0000 Subject: [PATCH] Don't default https://localhost.psim.us to HTTPS Anyone who wants to test on HTTPS can use localhost-443.psim.us. This can help with the issue where browsers prefer HTTPS over HTTP. There was an actual Cloudflare issue that made HTTP straight-up stop working for a while, but that one appears to be fixed now. --- js/clean-cookies.php | 2 +- js/client.js | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/js/clean-cookies.php b/js/clean-cookies.php index 10aa87c229..9086d78ecb 100644 --- a/js/clean-cookies.php +++ b/js/clean-cookies.php @@ -17,5 +17,5 @@ } if ($cleaned) { - echo 'alert("You had a cookie which was too big to handle and had to be deleted. If you had cookie settings, they may not be right.")'; + echo 'alert("You had a cookie which was too big to handle and had to be deleted. If you had cookie settings, they may have been deleted.")'; } diff --git a/js/client.js b/js/client.js index d32ae53e9d..4ab58ca347 100644 --- a/js/client.js +++ b/js/client.js @@ -756,6 +756,12 @@ function toId() { var self = this; var constructSocket = function () { + if (location.host === 'localhost.psim.us' || /[0-9]+.[0-9]+.[0-9]+.[0-9]+\.psim\.us/.test(location.host)) { + // normally we assume HTTPS means HTTPS, but make an exception for + // localhost and IPs which generally can't have a signed cert anyway. + Config.server.port = 8000; + Config.server.https = false; + } var protocol = (Config.server.port === 443 || Config.server.https) ? 'https' : 'http'; Config.server.host = $.trim(Config.server.host); try {