From eb8e95723c34efd9382a59cc1aaf26223a52b7e5 Mon Sep 17 00:00:00 2001 From: Blaz Kristan Date: Wed, 7 Jun 2023 21:37:54 +0200 Subject: [PATCH] Bugfix reverse proxy path detection --- wled00/data/index.htm | 2 +- wled00/data/index.js | 11 +- wled00/data/settings.htm | 9 +- wled00/data/settings_2D.htm | 9 +- wled00/data/settings_dmx.htm | 9 +- wled00/data/settings_leds.htm | 9 +- wled00/data/settings_sec.htm | 9 +- wled00/data/settings_sync.htm | 12 +- wled00/data/settings_time.htm | 9 +- wled00/data/settings_ui.htm | 9 +- wled00/data/settings_um.htm | 9 +- wled00/data/settings_wifi.htm | 9 +- wled00/html_settings.h | 3804 +++++++++++++++---------------- wled00/html_ui.h | 3952 ++++++++++++++++----------------- 14 files changed, 3936 insertions(+), 3926 deletions(-) diff --git a/wled00/data/index.htm b/wled00/data/index.htm index 2f35f38f..b8c0df85 100644 --- a/wled00/data/index.htm +++ b/wled00/data/index.htm @@ -363,7 +363,7 @@
- +

diff --git a/wled00/data/index.js b/wled00/data/index.js index 666d0440..6fa6d298 100644 --- a/wled00/data/index.js +++ b/wled00/data/index.js @@ -204,7 +204,8 @@ function getURL(path) { } function onLoad() { - if (window.location.protocol == "file:") { + let l = window.location; + if (l.protocol == "file:") { loc = true; locip = localStorage.getItem('locIp'); if (!locip) { @@ -213,12 +214,12 @@ function onLoad() } } else { // detect reverse proxy and/or HTTPS - let l = window.location; let pathn = l.pathname; let paths = pathn.slice(1,pathn.endsWith('/')?-1:undefined).split("/"); + //while (paths[0]==="") paths.shift(); locproto = l.protocol; - locip = l.hostname + (l.port ? ":" + l.port : "") - if (paths.length > 1) { + locip = l.hostname + (l.port ? ":" + l.port : ""); + if (paths.length > 0 && paths[0]!=="") { loc = true; locip += "/" + paths[0]; } else if (locproto==="https:") { @@ -2594,7 +2595,7 @@ function cnfReset() bt.innerHTML = "Confirm Reboot"; cnfr = true; return; } - window.location.href = "/reset"; + window.location.href = getURL("/reset"); } var cnfrS = false; diff --git a/wled00/data/settings.htm b/wled00/data/settings.htm index 4bebaef9..6488a5f2 100644 --- a/wled00/data/settings.htm +++ b/wled00/data/settings.htm @@ -27,7 +27,8 @@ }); } function S() { - if (window.location.protocol == "file:") { + let l = window.location; + if (l.protocol == "file:") { loc = true; locip = localStorage.getItem('locIp'); if (!locip) { @@ -36,12 +37,12 @@ } } else { // detect reverse proxy - let path = window.location.pathname; + let path = l.pathname; let paths = path.slice(1,path.endsWith('/')?-1:undefined).split("/"); if (paths.length > 1) { - locproto = window.location.protocol; + locproto = l.protocol; loc = true; - locip = window.location.hostname+window.location.port+"/"+paths[0]; + locip = l.hostname+l.port+"/"+paths[0]; } } loadJS(getURL('/settings/s.js?p=0'), false); // If we set async false, file is loaded and executed, then next statement is processed diff --git a/wled00/data/settings_2D.htm b/wled00/data/settings_2D.htm index 9fc1f927..4c417d46 100644 --- a/wled00/data/settings_2D.htm +++ b/wled00/data/settings_2D.htm @@ -35,7 +35,8 @@ }); } function S() { - if (window.location.protocol == "file:") { + let l = window.location; + if (l.protocol == "file:") { loc = true; locip = localStorage.getItem('locIp'); if (!locip) { @@ -44,12 +45,12 @@ } } else { // detect reverse proxy - let path = window.location.pathname; + let path = l.pathname; let paths = path.slice(1,path.endsWith('/')?-1:undefined).split("/"); if (paths.length > 2) { - locproto = window.location.protocol; + locproto = l.protocol; loc = true; - locip = window.location.hostname+window.location.port+"/"+paths[0]; + locip = l.hostname+l.port+"/"+paths[0]; } } loadJS(getURL('/settings/s.js?p=10'), false); // If we set async false, file is loaded and executed, then next statement is processed diff --git a/wled00/data/settings_dmx.htm b/wled00/data/settings_dmx.htm index 0589a203..28aa0d73 100644 --- a/wled00/data/settings_dmx.htm +++ b/wled00/data/settings_dmx.htm @@ -54,7 +54,8 @@ }); } function S(){ - if (window.location.protocol == "file:") { + let l = window.location; + if (l.protocol == "file:") { loc = true; locip = localStorage.getItem('locIp'); if (!locip) { @@ -63,12 +64,12 @@ } } else { // detect reverse proxy - let path = window.location.pathname; + let path = l.pathname; let paths = path.slice(1,path.endsWith('/')?-1:undefined).split("/"); if (paths.length > 2) { - locproto = window.location.protocol; + locproto = l.protocol; loc = true; - locip = window.location.hostname+window.location.port+"/"+paths[0]; + locip = l.hostname+l.port+"/"+paths[0]; } } loadJS(getURL('/settings/s.js?p=7'), false); // If we set async false, file is loaded and executed, then next statement is processed diff --git a/wled00/data/settings_leds.htm b/wled00/data/settings_leds.htm index 6e970a06..5c471878 100644 --- a/wled00/data/settings_leds.htm +++ b/wled00/data/settings_leds.htm @@ -547,7 +547,8 @@ Length: 2) { - locproto = window.location.protocol; + locproto = l.protocol; loc = true; - locip = window.location.hostname+window.location.port+"/"+paths[0]; + locip = l.hostname+l.port+"/"+paths[0]; } } loadJS(getURL('/settings/s.js?p=2'), false); // If we set async false, file is loaded and executed, then next statement is processed diff --git a/wled00/data/settings_sec.htm b/wled00/data/settings_sec.htm index b0af4e86..0d705967 100644 --- a/wled00/data/settings_sec.htm +++ b/wled00/data/settings_sec.htm @@ -65,7 +65,8 @@ x.setAttribute("download","wled_" + x.getAttribute("download") + (sd=="WLED"?"":("_" +sd))); } function S() { - if (window.location.protocol == "file:") { + let l = window.location; + if (l.protocol == "file:") { loc = true; locip = localStorage.getItem('locIp'); if (!locip) { @@ -74,12 +75,12 @@ } } else { // detect reverse proxy - let path = window.location.pathname; + let path = l.pathname; let paths = path.slice(1,path.endsWith('/')?-1:undefined).split("/"); if (paths.length > 2) { - locproto = window.location.protocol; + locproto = l.protocol; loc = true; - locip = window.location.hostname+window.location.port+"/"+paths[0]; + locip = l.hostname+l.port+"/"+paths[0]; } } loadJS(getURL('/settings/s.js?p=6'), false); // If we set async false, file is loaded and executed, then next statement is processed diff --git a/wled00/data/settings_sync.htm b/wled00/data/settings_sync.htm index 18ca2049..46e43ba6 100644 --- a/wled00/data/settings_sync.htm +++ b/wled00/data/settings_sync.htm @@ -6,7 +6,7 @@ Sync Settings