feat: detect LAN client via /api/client-ip for smart sidebar links
Deploy Dashboard / deploy (push) Successful in 1m10s
Deploy Dashboard / deploy (push) Successful in 1m10s
This commit is contained in:
@@ -114,6 +114,10 @@ async def startup_event():
|
|||||||
async def health():
|
async def health():
|
||||||
return {"status": "ok"}
|
return {"status": "ok"}
|
||||||
|
|
||||||
|
@app.get("/api/client-ip")
|
||||||
|
async def client_ip(request: Request):
|
||||||
|
return {"ip": request.client.host}
|
||||||
|
|
||||||
# Public auth endpoints
|
# Public auth endpoints
|
||||||
app.include_router(auth.router, prefix="/api/auth", tags=["auth"])
|
app.include_router(auth.router, prefix="/api/auth", tags=["auth"])
|
||||||
|
|
||||||
|
|||||||
@@ -12,10 +12,10 @@
|
|||||||
const TS_IP = "100.78.131.124";
|
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") {
|
||||||
fetch(`http://${LAN_IP}:4000/`, { mode: "no-cors", signal: AbortSignal.timeout(1500) })
|
fetch("/api/client-ip").then(r => r.json()).then(d => {
|
||||||
.then(() => { lanReachable = true; })
|
if (d.ip?.startsWith("192.168.31.")) lanReachable = true;
|
||||||
.catch(() => {});
|
}).catch(() => {});
|
||||||
}
|
}
|
||||||
|
|
||||||
const media = [
|
const media = [
|
||||||
|
|||||||
Reference in New Issue
Block a user