From bf15dad06167a584817d04120666f1365207f1aa Mon Sep 17 00:00:00 2001 From: "Gan, Jimmy" Date: Sun, 22 Feb 2026 16:45:31 +0800 Subject: [PATCH] Smart LAN detection for sidebar service links --- dashboard/frontend/src/components/Sidebar.svelte | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/dashboard/frontend/src/components/Sidebar.svelte b/dashboard/frontend/src/components/Sidebar.svelte index e80b7c1..40628e0 100644 --- a/dashboard/frontend/src/components/Sidebar.svelte +++ b/dashboard/frontend/src/components/Sidebar.svelte @@ -11,6 +11,15 @@ { id: "settings", label: "Settings", icon: "settings" }, ]; + const LAN_IP = "192.168.1.173"; + let lanReachable = $state(false); + + if (typeof window !== "undefined" && location.hostname !== LAN_IP) { + fetch(`http://${LAN_IP}:4000/`, { mode: "no-cors", signal: AbortSignal.timeout(1500) }) + .then(() => { lanReachable = true; }) + .catch(() => {}); + } + const external = [ { label: "Navidrome", href: "https://music.jimmygan.com", icon: "music" }, { label: "Immich", port: 2283, icon: "image" }, @@ -20,6 +29,9 @@ ]; function extHref(port) { + if (lanReachable && location.hostname !== LAN_IP) { + return `http://${LAN_IP}:${port}`; + } return `${location.protocol}//${location.hostname}:${port}`; }