mirror of
https://github.com/temetro/temetro.git
synced 2026-07-26 20:08:14 +00:00
403e0e38e9
Resolve the backend URL from the current host at runtime (lib/backend-url.ts) so one build works on localhost and any clinic LAN IP without a rebuild; used by the API client, auth client, and socket. Wire the AI-chat mic to the Web Speech API with graceful fallback. Add a Settings "About & updates" panel (current/latest version, update command, shareable network address) and an optional dismissible update banner. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
20 lines
630 B
TypeScript
20 lines
630 B
TypeScript
import { io, type Socket } from "socket.io-client";
|
|
|
|
import { resolveBackendUrl } from "@/lib/backend-url";
|
|
|
|
// A single shared Socket.io connection to the backend, authenticated by the
|
|
// Better Auth session cookie (withCredentials). Used by messaging and
|
|
// notifications. Created lazily on first use in the browser.
|
|
let socket: Socket | null = null;
|
|
|
|
export function getSocket(): Socket {
|
|
if (!socket) {
|
|
// Resolved lazily in the browser so it targets the host actually in use.
|
|
socket = io(resolveBackendUrl(), {
|
|
withCredentials: true,
|
|
transports: ["websocket", "polling"],
|
|
});
|
|
}
|
|
return socket;
|
|
}
|