Fix sidebar links: use Tailscale IP when accessed via public domain
Deploy Dashboard / deploy (push) Successful in 31s

This commit is contained in:
Gan, Jimmy
2026-02-25 00:22:54 +08:00
parent 6ae0cab143
commit adaaee1350
@@ -9,6 +9,7 @@
]; ];
const LAN_IP = "192.168.31.221"; const LAN_IP = "192.168.31.221";
const TS_IP = "100.78.131.124";
let lanReachable = $state(false); let lanReachable = $state(false);
if (typeof window !== "undefined" && location.hostname !== LAN_IP) { if (typeof window !== "undefined" && location.hostname !== LAN_IP) {
@@ -36,7 +37,10 @@
function extHref(svc) { function extHref(svc) {
if (lanReachable && svc.port) return `http://${LAN_IP}:${svc.port}`; if (lanReachable && svc.port) return `http://${LAN_IP}:${svc.port}`;
if (svc.remoteHref) return svc.remoteHref; if (svc.remoteHref) return svc.remoteHref;
if (svc.port) return `${location.protocol}//${location.hostname}:${svc.port}`; if (svc.port) {
const host = /^\d+\.\d+\.\d+\.\d+$/.test(location.hostname) ? location.hostname : TS_IP;
return `http://${host}:${svc.port}`;
}
return svc.href; return svc.href;
} }