fix(canary): vite dev proxy — correct backend port + stop stripping /api
Two latent template-leftover bugs in vite.config.ts proxy that 404'd every useTokenTypes/useCreateToken/useManageToken/useDeleteToken call: - Default target was http://localhost:8000. Backend listens on :8080 (backend/config.yaml `server.port: 8080`, default registered in internal/config/config.go). Off-by-one-port silent for the whole Phase 14 cycle because Phase 14 didn't end-to-end-test. - `rewrite: (p) => p.replace(/^\/api/, '')` stripped /api before forwarding. But backend mounts routes UNDER /api via `r.Route("/api", ...)` (cmd/canary/main.go:322). So a request for /api/tokens/types got rewritten to /tokens/types, which backend doesn't serve — 404 page not found. Frontend axios uses baseURL `/api` and path `/tokens/types` → full URL `/api/tokens/types`. With these fixes the proxy now passes that through verbatim to http://localhost:8080/api/tokens/types, which is where chi actually mounts the route. dev.compose.yml: added VITE_API_TARGET=http://canary:8080 to the frontend container's env so the dev-compose path also works (inside the container "localhost" is the vite container, not the canary container — has to use docker DNS). Surfaced today when the operator manually eyeballed the landing page and SpeciesSection rendered "Could not load species catalog. Try again in a moment." (the descriptorsError branch in landing/index.tsx SpeciesSection).
This commit is contained in:
parent
6ef5f68b59
commit
915d471b8d
|
|
@ -13,7 +13,7 @@ services:
|
|||
image: nginx:1.27-alpine
|
||||
container_name: ${APP_NAME:-canary-token-generator}-nginx-dev
|
||||
ports:
|
||||
- "${NGINX_HOST_PORT:-58495}:80"
|
||||
- "${NGINX_HOST_PORT:-22784}:80"
|
||||
volumes:
|
||||
- ./infra/nginx/nginx.conf:/etc/nginx/nginx.conf:ro
|
||||
- ./infra/nginx/dev.nginx:/etc/nginx/conf.d/default.conf:ro
|
||||
|
|
@ -38,6 +38,7 @@ services:
|
|||
- frontend_modules:/app/node_modules
|
||||
environment:
|
||||
- VITE_API_URL=${VITE_API_URL:-/api}
|
||||
- VITE_API_TARGET=${VITE_API_TARGET:-http://canary:8080}
|
||||
- VITE_APP_TITLE=${VITE_APP_TITLE:-Canary Token Generator}
|
||||
- VITE_TURNSTILE_SITE_KEY=${VITE_TURNSTILE_SITE_KEY:-}
|
||||
networks:
|
||||
|
|
|
|||
|
|
@ -32,9 +32,8 @@ export default defineConfig(({ mode }) => {
|
|||
host: '0.0.0.0',
|
||||
proxy: {
|
||||
'/api': {
|
||||
target: env.VITE_API_TARGET || 'http://localhost:8000',
|
||||
target: env.VITE_API_TARGET || 'http://localhost:8080',
|
||||
changeOrigin: true,
|
||||
rewrite: (p) => p.replace(/^\/api/, ''),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in New Issue