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:
@@ -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({
|
||||||
|
|||||||
@@ -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: [
|
||||||
|
|||||||
Reference in New Issue
Block a user