diff --git a/.env.example b/.env.example index 3b92d20..3155c0a 100644 --- a/.env.example +++ b/.env.example @@ -1,4 +1,3 @@ -VITE_API_BASE_URL=http://localhost/NesterApp/backend/api DB_HOST=localhost DB_NAME=nester_db DB_USER=root diff --git a/INSTALLATION.md b/INSTALLATION.md index 77df4e5..43d1224 100644 --- a/INSTALLATION.md +++ b/INSTALLATION.md @@ -31,10 +31,7 @@ ```bash npm install ``` - - Stelle sicher, dass deine `.env` die korrekte API-URL enthält: - ```env - VITE_API_BASE_URL=http://localhost/NesterApp/backend/api - ``` + - Die API-URL wird automatisch anhand des Servernamens ermittelt – keine manuelle Konfiguration nötig. - Starte den Entwicklungsserver: ```bash npm run dev diff --git a/src/services/nestService.js b/src/services/nestService.js index 8d60610..3beccd4 100644 --- a/src/services/nestService.js +++ b/src/services/nestService.js @@ -1,5 +1,9 @@ -// We will default to a common path structure, e.g. http://localhost/Taubennester/backend/api -export const API_BASE_URL = import.meta.env.VITE_API_BASE_URL || 'http://localhost/Taubennester/backend/api'; +// Dynamically resolve the API base URL from the current server's origin. +// This ensures the app works on any server without build-time configuration. +export const API_BASE_URL = (() => { + const { protocol, host } = window.location; + return `${protocol}//${host}/backend/api`; +})(); // Helper to build headers with token const getHeaders = (token) => {