From a5698c62bcfff98293c96b7dfa7af4b184126f67 Mon Sep 17 00:00:00 2001 From: iris Date: Wed, 29 Jul 2026 20:06:38 +0200 Subject: [PATCH 1/2] dev: make the client's dev-server proxy target configurable via WUTZ_SERVER_PORT MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit vite.config.ts hardcoded the /api, /admin, /healthz proxy targets to http://localhost:3000 — the server's default port — so there was no way to run dev:client against a dev:server started on a different port (PORT= pnpm dev:server) without editing the config file. Read the port from WUTZ_SERVER_PORT (same default of 3000 as the server's own PORT env var) and build the proxy target once. --- client/vite.config.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/client/vite.config.ts b/client/vite.config.ts index f4ecd25..c1e650b 100644 --- a/client/vite.config.ts +++ b/client/vite.config.ts @@ -3,6 +3,13 @@ import preact from '@preact/preset-vite'; import legacy from '@vitejs/plugin-legacy'; import { resolve } from 'node:path'; +// The dev-server proxy target — same default (3000) as the server's own +// `process.env.PORT ?? 3000` in server/src/index.ts. Override with +// `WUTZ_SERVER_PORT` when running `dev:server` on a non-default port, e.g.: +// PORT=4000 pnpm dev:server +// WUTZ_SERVER_PORT=4000 pnpm dev:client +const serverTarget = `http://localhost:${process.env.WUTZ_SERVER_PORT ?? 3000}`; + export default defineConfig({ plugins: [ preact(), @@ -24,9 +31,9 @@ export default defineConfig({ server: { port: 5173, proxy: { - '/api': 'http://localhost:3000', - '/admin': 'http://localhost:3000', - '/healthz': 'http://localhost:3000', + '/api': serverTarget, + '/admin': serverTarget, + '/healthz': serverTarget, }, }, }); From 32e3af3e231b056108b43eb0aa99b8a18b053ea1 Mon Sep 17 00:00:00 2001 From: iris Date: Wed, 29 Jul 2026 20:07:59 +0200 Subject: [PATCH 2/2] readme: document WUTZ_SERVER_PORT for running dev:client against a non-default dev:server port --- README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/README.md b/README.md index 15eb94b..6883bcf 100644 --- a/README.md +++ b/README.md @@ -91,6 +91,14 @@ pnpm dev:client # http://localhost:5173 (proxies /api Open `http://localhost:5173/` for the tablet UI and `http://localhost:5173/admin.html` for the backoffice. +Running `dev:server` on a non-default `PORT`? Point `dev:client`'s proxy at it with +`WUTZ_SERVER_PORT` (same value as `PORT`): + +```sh +PORT=4000 ADMIN_PASSWORD=changeme pnpm dev:server +WUTZ_SERVER_PORT=4000 pnpm dev:client +``` + ## 📦 Production build ```sh @@ -156,3 +164,6 @@ the service user owns the database directory automatically. - `ADMIN_PASSWORD` (**required** for backoffice login) - `WUTZ_TZ` (default `Europe/Berlin`) — timezone for stats display and grouping - `WUTZ_DAY_CUTOFF_HOUR` (default `5`) — sales before this local hour count toward the previous business day +- `WUTZ_SERVER_PORT` (default `3000`, **client dev only** — not read by the server) — the port + `dev:client`'s Vite proxy targets; set it to match `dev:server`'s `PORT` when running the server + on something other than the default