Files
parking_solution/apps/web/vite.config.ts
T
julian 6f4e390c05 feat(dev): bind Vite to 0.0.0.0 for LAN access (phone over wifi)
Vite had no host set (localhost only). Bind 0.0.0.0 so the dev booth UI is
reachable from other LAN devices at http://<host-lan-ip>:5173. The SPA
already uses relative paths + the page origin for API and the live WS, so
no app code changes — but loading from a non-localhost origin means the
/api/ws handshake's Origin is the LAN address, which the backend's
WS_ALLOWED_ORIGINS must include (documented in .env.example; the host's own
.env is gitignored).

Claude-Session: https://claude.ai/code/session_01Xcm6ikLgGoCxxHrxtjkk5V
2026-06-22 17:34:35 +02:00

36 lines
1.4 KiB
TypeScript

import react from "@vitejs/plugin-react";
import tailwindcss from "@tailwindcss/vite";
import { defineConfig } from "vite";
// Operator SPA. Built by Vite and served by Fastify in production
// (see wiki/entities/react-vite-spa.md). The dev proxy points the API at the
// local Fastify server.
export default defineConfig({
plugins: [react(), tailwindcss()],
server: {
port: 5173,
// Bind all interfaces so the dev SPA is reachable from other LAN devices
// (phone over wifi, etc.) at http://<host-lan-ip>:5173 — not just localhost.
// NB: loading from a non-localhost origin means the booth WebSocket (/api/ws)
// sends Origin: http://<host-lan-ip>:5173, which the backend's WS_ALLOWED_ORIGINS
// must include or the live feed is rejected. See apps/server/.env(.example).
host: "0.0.0.0",
proxy: {
// Use 127.0.0.1 (not "localhost") so the proxy never tries IPv6 ::1
// first and stall — the backend binds IPv4. Avoids slow/hung requests,
// notably under WSL2 mirrored networking.
"/api": {
target: "http://127.0.0.1:3000",
// The live booth feed (/api/ws) is a WebSocket — without `ws: true` the
// proxy would not forward the upgrade. The backend's Origin allowlist must
// include the dev origin (http://localhost:5173) via WS_ALLOWED_ORIGINS.
ws: true,
},
"/health": "http://127.0.0.1:3000",
},
},
build: {
outDir: "dist",
},
});