This repository has been archived on 2026-10-08. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
maestro/web/vite.config.ts
T
naps62-yolo f0b01ae295
ci / rust (push) Successful in 1m27s
feat(maestro): let vite dev proxy honor \$MAESTRO_REGISTRY
`web/vite.config.ts` was hard-coded to proxy `/api` at
`http://127.0.0.1:8080`, so pointing the dev UI at a remote registry meant
hand-editing the file. Read `MAESTRO_REGISTRY` from the environment via
`loadEnv` instead, with the local default preserved. Accept either the HTTP
base URL (`https://…`) or the daemon-facing URL (`wss://…/daemon`) — the
latter is rewritten to `https://…` and the `/daemon` suffix stripped, since
the proxy needs the HTTP origin. Flips `changeOrigin: true` for HTTPS
upstreams so the proxied Host matches the cert.

Documented under `web/README.md` § Dev.
2026-05-25 15:35:57 +00:00

42 lines
1.2 KiB
TypeScript

import { defineConfig, loadEnv } from "vite";
// Where the dev proxy forwards `/api/*` (and the events WS) to. Default to a
// local `maestro-registry` on 127.0.0.1:8080. Override by exporting either:
// MAESTRO_REGISTRY=https://maestro-registry.example.com (preferred)
// MAESTRO_REGISTRY=wss://maestro-registry.example.com/daemon
// The second form (the daemon-facing URL) is normalised: ws/wss → http/https
// and any trailing `/daemon` is stripped, since the proxy needs the base URL.
function resolveProxyTarget(raw: string | undefined): string {
if (!raw) return "http://127.0.0.1:8080";
return raw
.replace(/^wss:\/\//, "https://")
.replace(/^ws:\/\//, "http://")
.replace(/\/daemon\/?$/, "")
.replace(/\/+$/, "");
}
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd(), "");
const target = resolveProxyTarget(env.MAESTRO_REGISTRY);
const secure = target.startsWith("https://");
return {
build: {
target: "es2022",
outDir: "dist",
emptyOutDir: true,
sourcemap: false,
},
server: {
port: 5173,
proxy: {
"/api": {
target,
changeOrigin: secure,
ws: true,
secure: false,
},
},
},
};
});