local-dev: Vite proxy for same-origin requests + upstream gateway Dockerfile fix
vite.config.ts now proxies `/api` and `/galaxy.gateway.v1.EdgeGateway` to the gateway, so the browser sees only `localhost:5173` and never trips a cross-origin preflight. `.env.development` accordingly points `VITE_GATEWAY_BASE_URL` at the Vite origin. The proxy target is overridable via `VITE_DEV_PROXY_TARGET=...` for non-default gateways without touching the compose file. `gateway/Dockerfile` previously failed to build because gateway imports `galaxy/core` (replaced to `../ui/core` in `gateway/go.mod`) but the Dockerfile did not copy `ui/core/` into the build context nor declare the replace in the synthesised `go.work`. Adding both makes `docker build -f gateway/Dockerfile .` succeed; this is the same fix already shipped in `tools/local-dev/gateway.Dockerfile`, back-ported to upstream. Verified: - docker build -f gateway/Dockerfile . — builds cleanly - pnpm test 14/14, pnpm exec playwright test 44/44 (with CI=1 to force a fresh dev server; reuse keeps the previous startup env) - curl POST through localhost:5173/api/* and /galaxy.gateway.v1.* — reach the gateway, no CORS preflight on the browser side tools/local-dev/README.md updated with the new network map and the `VITE_DEV_PROXY_TARGET` override. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
+27
-15
@@ -72,23 +72,35 @@ the backend with the new env).
|
||||
## Network map
|
||||
|
||||
```
|
||||
host compose network "galaxy-local-dev-net"
|
||||
┌────────────────────────────┐ ┌──────────────────────────────┐
|
||||
│ pnpm dev localhost:5173 │──HMR──▶│ host (Vite) │
|
||||
│ browser localhost:8080 │──REST/Connect─▶│ gateway:8080 │
|
||||
│ browser localhost:8025 │─────▶│ mailpit:8025 (web UI) │
|
||||
│ psql localhost:5433 │─────▶│ postgres:5432 │
|
||||
│ redis-cli localhost:6380 │─────▶│ redis:6379 │
|
||||
└────────────────────────────┘ │ ↳ backend:8080 (HTTP) │
|
||||
│ ↳ backend:8081 (gRPC push) │
|
||||
│ ↳ mailpit:1025 (SMTP in) │
|
||||
└──────────────────────────────┘
|
||||
host compose network "galaxy-local-dev-net"
|
||||
┌────────────────────────────────┐ ┌──────────────────────────────┐
|
||||
│ browser localhost:5173 │── pnpm dev (Vite, host) ──┐ │
|
||||
│ ↳ /api/* proxied ───┼──────────────────────────▶│ gateway:8080 │
|
||||
│ ↳ /galaxy.gateway... ┼──────────────────────────▶│ │
|
||||
│ browser localhost:8025 │─────────────────────────▶│ mailpit:8025 │
|
||||
│ psql localhost:5433 │─────────────────────────▶│ postgres:5432 │
|
||||
│ redis-cli localhost:6380 │─────────────────────────▶│ redis:6379 │
|
||||
└────────────────────────────────┘ │ ↳ backend:8080 (HTTP) │
|
||||
│ ↳ backend:8081 (gRPC push) │
|
||||
│ ↳ mailpit:1025 (SMTP in) │
|
||||
└────────────────────────────────┘
|
||||
```
|
||||
|
||||
Only the gateway public port (8080) and the mailpit web UI (8025)
|
||||
are needed for normal UI work. Postgres (5433) and Redis (6380) are
|
||||
exposed for direct inspection (`make psql`, `redis-cli -h localhost
|
||||
-p 6380 -a galaxy-dev`).
|
||||
Vite's dev server proxies `/api` and `/galaxy.gateway.v1.EdgeGateway`
|
||||
to the gateway, so every browser request stays same-origin (no CORS
|
||||
preflight). The gateway is therefore reachable only through Vite at
|
||||
<http://localhost:5173>, not at <http://localhost:8080> from the
|
||||
browser tab. Direct curl/wget against <http://localhost:8080> still
|
||||
works for diagnostic probes — only the browser-side requests are
|
||||
proxied.
|
||||
|
||||
Mailpit (8025), postgres (5433), and redis (6380) remain directly
|
||||
reachable for diagnostics (`make psql`, `redis-cli -h localhost -p
|
||||
6380 -a galaxy-dev`).
|
||||
|
||||
To point the proxy at a non-local gateway, run
|
||||
`VITE_DEV_PROXY_TARGET=http://gateway.host:8080 pnpm -C ui/frontend dev`
|
||||
— no compose changes needed.
|
||||
|
||||
## Make targets
|
||||
|
||||
|
||||
Reference in New Issue
Block a user