Vite : retirer le préfixe /api avant de forwarder au backend
Le proxy dev transmettait /api/editions/... tel quel → 404 (les routes du backend sont sous /editions/...). Ajout d'un `rewrite` qui enlève /api.
This commit is contained in:
@@ -15,9 +15,12 @@ export default defineConfig({
|
|||||||
host: true,
|
host: true,
|
||||||
port: 5173,
|
port: 5173,
|
||||||
proxy: {
|
proxy: {
|
||||||
|
// Le back-end expose ses routes sous `/editions/...` (pas `/api`) :
|
||||||
|
// on retire le préfixe avant de forwarder.
|
||||||
'/api': {
|
'/api': {
|
||||||
target: process.env.VITE_API_TARGET ?? 'http://localhost:8000',
|
target: process.env.VITE_API_TARGET ?? 'http://localhost:8000',
|
||||||
changeOrigin: true,
|
changeOrigin: true,
|
||||||
|
rewrite: (path) => path.replace(/^\/api/, ''),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user