Compare commits

...
Author SHA1 Message Date
iris
32e3af3e23 readme: document WUTZ_SERVER_PORT for running dev:client against a non-default dev:server port 2026-07-29 20:07:59 +02:00
iris
a5698c62bc dev: make the client's dev-server proxy target configurable via WUTZ_SERVER_PORT
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=<n> 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.
2026-07-29 20:06:38 +02:00
2 changed files with 21 additions and 3 deletions

View file

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

View file

@ -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,
},
},
});