fix: use backend service name in Vite proxy target
Vite runs inside the frontend container where 'localhost' resolves to the container itself, not the backend. Change the /api proxy target from http://localhost:8000 to http://backend:8000 so the request is routed to the backend service over the compose network.
This commit is contained in:
@@ -130,10 +130,15 @@ frontend/
|
||||
├── .eslintrc.cjs
|
||||
├── .prettierrc
|
||||
├── tsconfig.json
|
||||
├── vite.config.ts
|
||||
├── vite.config.ts # Dev proxy: /api → http://backend:8000 (service DNS)
|
||||
└── package.json
|
||||
```
|
||||
|
||||
> **Dev proxy target:** `vite.config.ts` proxies all `/api` requests to
|
||||
> `http://backend:8000`. Use the compose **service name** (`backend`), not
|
||||
> `localhost` — inside the container network `localhost` resolves to the
|
||||
> frontend container itself and causes `ECONNREFUSED`.
|
||||
|
||||
### Separation of Concerns
|
||||
|
||||
- **Pages** handle routing and compose layout + components — they contain no business logic.
|
||||
|
||||
Reference in New Issue
Block a user