From bd2a166253a14fc7f356bed9a9821f2a6e1f4c77 Mon Sep 17 00:00:00 2001 From: "Gan, Jimmy" Date: Sun, 1 Mar 2026 22:55:37 +0800 Subject: [PATCH] fix: use hybrid sidebar links for LAN and public access Keep LAN/Tailscale-home behavior for NAS-targeted links while converting remote :8443 URLs to standard HTTPS on public access so external links resolve correctly. Co-Authored-By: Claude Opus 4.6 (1M context) --- .../frontend/src/components/Sidebar.svelte | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/dashboard/frontend/src/components/Sidebar.svelte b/dashboard/frontend/src/components/Sidebar.svelte index b4dca40..7242961 100644 --- a/dashboard/frontend/src/components/Sidebar.svelte +++ b/dashboard/frontend/src/components/Sidebar.svelte @@ -169,9 +169,28 @@ handleDragEnd(); } + function toPublicHttpsUrl(href) { + if (typeof window === "undefined") return href; + if (!href) return href; + + const isStandardHttps = location.protocol === "https:" && (!location.port || location.port === "443"); + if (!isStandardHttps) return href; + + try { + const url = new URL(href); + if (url.protocol === "https:" && url.port === "8443") { + url.port = ""; + return url.toString(); + } + return href; + } catch { + return href; + } + } + function extHref(svc) { if (lanReachable && svc.port) return `http://${LAN_IP}:${svc.port}`; - if (svc.remoteHref) return svc.remoteHref; + if (svc.remoteHref) return lanReachable ? svc.remoteHref : toPublicHttpsUrl(svc.remoteHref); if (svc.port) { const host = /^\d+\.\d+\.\d+\.\d+$/.test(location.hostname) ? location.hostname : TS_IP; return `http://${host}:${svc.port}`;