Steps to Reproduce
- Start local Docker environment:
docker compose up
- Navigate to frontend at
http://localhost:3000
- Trigger any API call (e.g., fetch medication list)
- Observe error in browser console and Vite terminal
Possible Fix: Vite proxy
Background
The API client uses relative URLs (/api/...), so requests go to the frontend's origin unless a proxy forwards them to the backend. In development, Vite runs a Node.js server that serves the React app and can proxy requests. In production, Vite compiles React into static files served by nginx or a CDN — the infrastructure handles API routing instead.
Fix
Add a proxy to frontend/vite.config.ts:
server: {
proxy: {
'/api': {
target: 'http://backend:8000',
changeOrigin: true,
},
},
},
Rebuild with docker compose down && docker compose up --build.
Steps to Reproduce
docker compose uphttp://localhost:3000Possible Fix: Vite proxy
Background
The API client uses relative URLs (/api/...), so requests go to the frontend's origin unless a proxy forwards them to the backend. In development, Vite runs a Node.js server that serves the React app and can proxy requests. In production, Vite compiles React into static files served by nginx or a CDN — the infrastructure handles API routing instead.
Fix
Add a proxy to frontend/vite.config.ts:
Rebuild with docker compose down && docker compose up --build.