From a5698c62bcfff98293c96b7dfa7af4b184126f67 Mon Sep 17 00:00:00 2001 From: iris Date: Wed, 29 Jul 2026 20:06:38 +0200 Subject: [PATCH] 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, }, }, });