Controller: link to the main UI on :8443 for Docker installs (#1029)

The fallback Controller UI picked the main UI's port by sniffing its own URL:
only port 8080 mapped to 8443, and any https page dropped the port. Loaded
from https://host:8443/controller/, the Continue/Proceed links pointed at
https://host/. All four links now share one base chosen by docker_mode.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
lrnselfreliance 2026-11-28 12:49:43 -07:00 • committed by GitHub
parent b372a5fc90
commit 633b125dc6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 28 additions and 29 deletions

View file

@ -1290,13 +1290,14 @@
<script>
/* ===== INLINE JAVASCRIPT - No external files ===== */
// The main WROLPi UI: Docker serves it on 8443, native on 443. The Controller may be reached on any port
// (Docker: 8080 or 8443/controller/), so the port is chosen by deployment, never by the current URL.
var WROLPI_HTTPS_BASE = 'https://' + window.location.hostname
+ ({{ 'true' if docker_mode else 'false' }} ? ':8443' : '');
// Certificate trust detection.
(function() {
var host = window.location.hostname;
var port = window.location.port;
// Docker: 8080 → 8443; native: 80/empty → 443 (default).
var httpsPort = (port === '8080') ? ':8443' : '';
var httpsBase = 'https://' + host + httpsPort;
var httpsBase = WROLPI_HTTPS_BASE;
// Set the "Continue to WROLPi" link.
var continueBtn = document.getElementById('cert-continue-btn');
@ -2685,15 +2686,7 @@
currentScriptOutput = 'upgrade';
}
const upgradeIsDocker = {{ 'true' if docker_mode else 'false' }};
let upgradeHttpsBase;
if (window.location.protocol === 'https:') {
upgradeHttpsBase = `https://${window.location.hostname}`;
} else if (upgradeIsDocker) {
upgradeHttpsBase = `https://${window.location.hostname}:8443`;
} else {
upgradeHttpsBase = `https://${window.location.hostname}`;
}
const upgradeHttpsBase = WROLPI_HTTPS_BASE;
// Two-phase upgrade detection:
// Phase 1: Wait for services to go DOWN (confirms upgrade actually started).
@ -2834,16 +2827,7 @@
if (resp.ok) {
const data = await resp.json();
if (data.api && data.app) {
const isDocker = {{ 'true' if docker_mode else 'false' }};
let httpsBase;
if (window.location.protocol === 'https:') {
httpsBase = `https://${window.location.hostname}`;
} else if (isDocker) {
httpsBase = `https://${window.location.hostname}:8443`;
} else {
httpsBase = `https://${window.location.hostname}`;
}
window.location.href = `${httpsBase}/`;
window.location.href = `${WROLPI_HTTPS_BASE}/`;
}
}
} catch (e) {
@ -3065,11 +3049,7 @@
return (s.name === 'caddy' || s.name === 'web') && s.status === 'running';
});
if (appReady) {
var host = window.location.hostname;
var port = window.location.port;
// Docker: 8080 → 8443; native: 80/empty → 443 (default).
var httpsPort = (port === '8080') ? ':8443' : '';
var httpsBase = 'https://' + host + httpsPort;
var httpsBase = WROLPI_HTTPS_BASE;
proceedBtn.href = httpsBase;
proceedBtn.style.display = 'inline-block';
var viewFilesBtn = document.getElementById('view-files-btn');

View file

@ -72,6 +72,25 @@ class TestDashboardEndpoint:
assert 'class="toggle"' in content
assert "Running in Docker mode" not in content
@staticmethod
def _rendered_wrolpi_port(content: str) -> str:
match = re.search(r"var WROLPI_HTTPS_BASE = 'https://' \+ window\.location\.hostname\s*"
r"\+ \((true|false) \? ':8443' : ''\);", content)
assert match, "WROLPI_HTTPS_BASE was not rendered"
# Every WROLPi link derives from the one base; none sniff the Controller's own port/protocol.
assert "port === '8080'" not in content
assert "window.location.protocol === 'https:'" not in content
return ":8443" if match.group(1) == "true" else ""
def test_dashboard_wrolpi_links_docker_port(self, test_client_docker_mode):
"""Docker: "Continue/Proceed to WROLPi" links use 8443 even when the Controller is loaded from
https://host:8443/controller/ or http://host:8080/."""
assert self._rendered_wrolpi_port(test_client_docker_mode.get("/").text) == ":8443"
def test_dashboard_wrolpi_links_native_port(self, test_client):
"""Native: "Continue/Proceed to WROLPi" links use the default HTTPS port."""
assert self._rendered_wrolpi_port(test_client.get("/").text) == ""
def test_dashboard_docker_mode_shows_banner_and_hides_boot_column(self, test_client_docker_mode):
"""Docker mode: Docker banner visible, no Boot toggles in rendered tbody."""
response = test_client_docker_mode.get("/")