Angepass an Produtionumgebung
This commit is contained in:
@@ -1,6 +1,13 @@
|
||||
import { defineConfig } from 'vite'
|
||||
import react from '@vitejs/plugin-react'
|
||||
|
||||
// Im Dev-Modus laufen Frontend (5173) und Backend (3001) getrennt.
|
||||
// Damit das Frontend trotzdem relative URLs ("/api/...") verwenden kann,
|
||||
// proxyt Vite alle /api-Anfragen an das Backend. Das Ziel ist konfigurierbar:
|
||||
// - lokal ohne Docker: http://localhost:3001 (Standard)
|
||||
// - Docker-Dev: VITE_PROXY_TARGET=http://backend:3001
|
||||
const proxyTarget = process.env.VITE_PROXY_TARGET || 'http://localhost:3001'
|
||||
|
||||
// https://vite.dev/config/
|
||||
export default defineConfig({
|
||||
plugins: [react()],
|
||||
@@ -9,6 +16,12 @@ export default defineConfig({
|
||||
port: 5173,
|
||||
watch: {
|
||||
usePolling: true
|
||||
},
|
||||
proxy: {
|
||||
'/api': {
|
||||
target: proxyTarget,
|
||||
changeOrigin: true
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user