feat(frontend): Anpassung der Vite-Konfiguration und Verbesserung der API-Basis-URL

- Hinzufügen von Umgebungsvariablen zur Vite-Konfiguration für die Produktionsumgebung.
- Anpassung der API-Basis-URL in axios.js, um sicherzustellen, dass immer der Apache-Proxy für die Produktion verwendet wird.
This commit is contained in:
Torsten Schulz (local)
2025-08-29 09:20:06 +02:00
parent 7b9279ef29
commit bc4397bcae
2 changed files with 9 additions and 8 deletions

View File

@@ -1,24 +1,18 @@
import axios from 'axios'; import axios from 'axios';
import store from '../store'; import store from '../store';
// API-Basis-URL basierend auf der Umgebung // API-Basis-URL - immer über Apache-Proxy für Produktion
const getApiBaseURL = () => { const getApiBaseURL = () => {
// Wenn explizite Umgebungsvariable gesetzt ist, diese verwenden // Wenn explizite Umgebungsvariable gesetzt ist, diese verwenden
if (import.meta.env.VITE_API_BASE_URL) { if (import.meta.env.VITE_API_BASE_URL) {
return import.meta.env.VITE_API_BASE_URL; return import.meta.env.VITE_API_BASE_URL;
} }
// In Entwicklung: direkte Backend-Verbindung // Für Produktion: immer über Apache-Proxy
if (import.meta.env.DEV) {
return 'http://localhost:3001';
}
// In Produktion: über Apache-Proxy
return '/api'; return '/api';
}; };
// Debug-Informationen // Debug-Informationen
console.log('🌍 Environment:', import.meta.env.MODE);
console.log('🔗 API Base URL:', getApiBaseURL()); console.log('🔗 API Base URL:', getApiBaseURL());
const apiClient = axios.create({ const apiClient = axios.create({

View File

@@ -6,6 +6,13 @@ import path from 'path';
export default defineConfig({ export default defineConfig({
plugins: [vue()], plugins: [vue()],
define: {
// Explizit Produktionsumgebung setzen
__DEV__: false,
'import.meta.env.DEV': false,
'import.meta.env.PROD': true,
'import.meta.env.MODE': '"production"'
},
optimizeDeps: { optimizeDeps: {
esbuildOptions: { esbuildOptions: {
plugins: [ plugins: [