Commit ed765603 authored by Hendrik Garske's avatar Hendrik Garske

Fix: Vereinfache Backend-URL fuer gleichen Container (localhost:51821)

parent 04c7f705
...@@ -70,27 +70,15 @@ Die Anwendung läuft jetzt auf [http://localhost:3000](http://localhost:3000) ...@@ -70,27 +70,15 @@ Die Anwendung läuft jetzt auf [http://localhost:3000](http://localhost:3000)
### Backend-Konfiguration ### Backend-Konfiguration
⚠️ **Das wg-easy Backend muss separat laufen!** **Wenn Frontend und Backend im gleichen Docker Container laufen:**
Die Anwendung versucht **automatisch**, das Backend zu finden. Es werden verschiedene URLs ausprobiert: Die Anwendung verwendet automatisch `http://localhost:51821` als Backend-URL (Standard-Port für wg-easy).
1. **Automatische Erkennung:** **Standardwerte (keine Konfiguration erforderlich):**
- `http://localhost:51821` (Standard, wenn beide im gleichen Container) - **WG_API_URL**: `http://localhost:51821` (für gleichen Container)
- `http://127.0.0.1:51821`
- `http://wg-easy:51821` (Docker Service-Name)
- `http://srv-captain--wg-easy:51821` (CapRover Service-Name)
- Weitere Varianten werden automatisch ausprobiert
2. **Falls Backend nicht gefunden wird:**
- Stelle sicher, dass das wg-easy Backend läuft
- Prüfe in CapRover, auf welcher URL/Port das Backend erreichbar ist
- Setze optional `WG_API_URL` als Environment Variable in CapRover auf die tatsächliche Backend-URL
**Standardwerte:**
- **WG_API_URL**: Automatische Erkennung (keine Konfiguration erforderlich, wenn Backend auf Standard-Port läuft)
- **WG_PASSWORD**: `CoreX2024!Secure#VPN` - **WG_PASSWORD**: `CoreX2024!Secure#VPN`
**Hinweis:** Wenn das Backend nicht automatisch gefunden wird, setze `WG_API_URL` in CapRover als Environment Variable auf die tatsächliche Backend-URL (z.B. `http://srv-captain--backend-name:51821` oder externe URL). **Wichtig:** Stelle sicher, dass das wg-easy Backend auch im Container läuft und auf Port 51821 hört!
## 🐳 Docker Setup ## 🐳 Docker Setup
......
...@@ -8,7 +8,7 @@ function getWgApiUrl(): string { ...@@ -8,7 +8,7 @@ function getWgApiUrl(): string {
} }
// Standard-URL (wg-easy Backend läuft normalerweise auf Port 51821) // Standard-URL (wg-easy Backend läuft normalerweise auf Port 51821)
// In CapRover: Wenn beide in der gleichen App, versuche verschiedene Optionen // Wenn beide im gleichen Container laufen, verwende localhost
return 'http://localhost:51821' return 'http://localhost:51821'
} }
...@@ -68,19 +68,11 @@ export class WgApiClient { ...@@ -68,19 +68,11 @@ export class WgApiClient {
private async request<T>(endpoint: string, options: RequestInit = {}): Promise<T> { private async request<T>(endpoint: string, options: RequestInit = {}): Promise<T> {
// Liste möglicher Backend-URLs zum Ausprobieren // Liste möglicher Backend-URLs zum Ausprobieren
// Hinweis: Port 51821 ist der Standard-Port für wg-easy Web-UI // Hinweis: Port 51821 ist der Standard-Port für wg-easy Web-UI
// Wenn das Backend auf einem anderen Port läuft, muss WG_API_URL als Environment Variable gesetzt werden // Wenn beide im gleichen Container laufen, sollte localhost funktionieren
const possibleUrls = [ const possibleUrls = [
this.baseUrl, // Zuerst die konfigurierte URL versuchen this.baseUrl, // Zuerst die konfigurierte URL versuchen (Standard: localhost:51821)
'http://localhost:51821', 'http://localhost:51821', // Standard für gleichen Container
'http://127.0.0.1:51821', 'http://127.0.0.1:51821', // Alternative localhost-Variante
'http://localhost:51820', // Alternative Port
'http://wg-easy:51821',
'http://wg-easy:51820',
'http://srv-captain--wg-easy:51821',
'http://srv-captain--wg-easy:51820',
// Versuche auch mögliche CapRover Service-Namen
'http://srv-captain--corex-wg-easy:51821',
'http://srv-captain--corex-wg-easy:51820',
] ]
let lastError: Error | null = null let lastError: Error | null = null
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment