feat: smart LAN detection for sidebar links via X-Forwarded-For and router probe

This commit is contained in:
Gan, Jimmy
2026-02-26 03:11:13 +08:00
parent 22e9066ffe
commit 879ae4b6a3
2 changed files with 21 additions and 4 deletions
@@ -12,10 +12,10 @@
const TS_IP = "100.78.131.124";
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(() => {});
if (typeof window !== "undefined") {
fetch("/api/client-ip").then(r => r.json()).then(d => {
if (d.lan) lanReachable = true;
}).catch(() => {});
}
const media = [