From 96da009086ac6ea0eb3413046e3976c757686123 Mon Sep 17 00:00:00 2001 From: teernisse Date: Fri, 30 Jan 2026 01:08:46 -0500 Subject: [PATCH] Remove hardcoded Tailscale IP, bind server and Vite to localhost only The Express server was binding to both 127.0.0.1 and a specific Tailscale IP (100.84.4.113), creating two separate http.Server instances. Simplify to a single localhost binding. Also update Vite dev server to use 127.0.0.1 instead of the Tailscale IP and disable the HMR error overlay which obscures the UI during development. Co-Authored-By: Claude Opus 4.5 --- src/server/index.ts | 13 +++---------- vite.config.ts | 8 ++++---- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/src/server/index.ts b/src/server/index.ts index 8c4183e..71ec55c 100644 --- a/src/server/index.ts +++ b/src/server/index.ts @@ -28,18 +28,12 @@ export function createApp() { return app; } -const TAILSCALE_IP = "100.84.4.113"; - export function startServer() { const PORT = parseInt(process.env.PORT || "3848", 10); const app = createApp(); - // Bind to both localhost and Tailscale — not the public interface - const localServer = app.listen(PORT, "127.0.0.1", () => { + const server = app.listen(PORT, "127.0.0.1", async () => { console.log(`Session Viewer API running on http://localhost:${PORT}`); - }); - const tsServer = app.listen(PORT, TAILSCALE_IP, async () => { - console.log(`Session Viewer API running on http://${TAILSCALE_IP}:${PORT}`); if (process.env.SESSION_VIEWER_OPEN_BROWSER === "1") { const { default: open } = await import("open"); open(`http://localhost:${PORT}`); @@ -48,13 +42,12 @@ export function startServer() { // Graceful shutdown so tsx watch can restart cleanly function shutdown() { - localServer.close(); - tsServer.close(); + server.close(); } process.on("SIGINT", shutdown); process.on("SIGTERM", shutdown); - return tsServer; + return server; } // Only auto-start when run directly (not imported by tests) diff --git a/vite.config.ts b/vite.config.ts index 701546a..25c0864 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -12,10 +12,10 @@ export default defineConfig({ }, server: { port: 3847, - // Vite only supports one host. Use Tailscale IP so it's reachable - // from both the local machine (via the TS IP) and the tailnet. - // localhost:3847 won't work for the Vite dev server — use the TS IP. - host: "100.84.4.113", + host: "127.0.0.1", + hmr: { + overlay: false, + }, proxy: { "/api": { target: "http://127.0.0.1:3848",