Le proxy dev transmettait /api/editions/... tel quel → 404 (les routes du backend sont sous /editions/...). Ajout d'un `rewrite` qui enlève /api.
28 lines
723 B
TypeScript
28 lines
723 B
TypeScript
import { fileURLToPath, URL } from 'node:url';
|
|
|
|
import { defineConfig } from 'vite';
|
|
import react from '@vitejs/plugin-react';
|
|
|
|
// Le backend tourne sur :8000 en dev (voir docker-compose.yml).
|
|
export default defineConfig({
|
|
plugins: [react()],
|
|
resolve: {
|
|
alias: {
|
|
'@': fileURLToPath(new URL('./src', import.meta.url)),
|
|
},
|
|
},
|
|
server: {
|
|
host: true,
|
|
port: 5173,
|
|
proxy: {
|
|
// Le back-end expose ses routes sous `/editions/...` (pas `/api`) :
|
|
// on retire le préfixe avant de forwarder.
|
|
'/api': {
|
|
target: process.env.VITE_API_TARGET ?? 'http://localhost:8000',
|
|
changeOrigin: true,
|
|
rewrite: (path) => path.replace(/^\/api/, ''),
|
|
},
|
|
},
|
|
},
|
|
});
|