Smart LAN detection for sidebar service links
This commit is contained in:
@@ -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}`;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user