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 <noreply@anthropic.com>
This commit is contained in:
2026-01-30 01:08:46 -05:00
parent 8e713b9c50
commit 96da009086
2 changed files with 7 additions and 14 deletions

View File

@@ -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)

View File

@@ -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",