Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
CoreX-wg-easy
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Hendrik Garske
CoreX-wg-easy
Commits
ed053abc
Commit
ed053abc
authored
Dec 27, 2025
by
Hendrik Garske
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix: Verbesserte Fehlerbehandlung und Dokumentation fuer Backend-URL
parent
ad73fe4c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
55 additions
and
33 deletions
+55
-33
README.md
README.md
+16
-10
wg-api.ts
lib/wg-api.ts
+39
-23
No files found.
README.md
View file @
ed053abc
...
@@ -68,20 +68,26 @@ Die Anwendung läuft jetzt auf [http://localhost:3000](http://localhost:3000)
...
@@ -68,20 +68,26 @@ Die Anwendung läuft jetzt auf [http://localhost:3000](http://localhost:3000)
**Wichtig:**
Die Anwendung benötigt eine WireGuard Easy Backend-Instanz.
**Wichtig:**
Die Anwendung benötigt eine WireGuard Easy Backend-Instanz.
### Backend-Konfiguration
### Backend-Konfiguration
in CapRover
Wenn Frontend und Backend in der
**gleichen CapRover App**
laufen:
Wenn Frontend und Backend in der
**gleichen CapRover App**
laufen
, muss das Backend über die richtige URL erreichbar sein
:
1.
**Backend-URL**
: Standardmäßig verwendet die App
`http://localhost:51821`
1.
**Backend-URL ermitteln:**
-
Falls das Backend als separater Container im Stack läuft, verwende den Service-Namen
-
Wenn das Backend als
**separater CapRover Service**
läuft: Verwende die externe URL des Backends
-
In CapRover kann optional
`WG_API_URL`
als Environment Variable gesetzt werden
-
Beispiel:
`https://wg-easy-backend.corexmanagement.de`
-
Wenn beide im
**gleichen Container**
laufen:
`http://localhost:51821`
-
Wenn Backend als
**Docker Service**
im Stack: Verwende Service-Namen (z.B.
`http://wg-easy-backend:51821`
)
2.
**Backend-Passwort**
: Standard ist
`CoreX2024!Secure#VPN`
2.
**Environment Variable setzen:**
-
Optional:
`WG_PASSWORD`
als Environment Variable in CapRover setzen
-
In CapRover: App → Environment Variables
-
`WG_API_URL`
: URL des wg-easy Backends
-
`WG_PASSWORD`
: Backend-Passwort (Standard:
`CoreX2024!Secure#VPN`
)
**Standardwerte (wenn keine Environment Variables gesetzt):**
3.
**Standardwerte (falls keine Environment Variables gesetzt):**
-
**WG_API_URL**
:
`http://localhost:51821`
(für gleiche CapRover App)
-
**WG_API_URL**
:
`https://corex-wg-easy.corexmanagement.de`
(Frontend-URL - muss angepasst werden!)
-
**WG_PASSWORD**
:
`CoreX2024!Secure#VPN`
-
**WG_PASSWORD**
:
`CoreX2024!Secure#VPN`
**⚠️ Wichtig:**
Setze
`WG_API_URL`
in CapRover auf die tatsächliche Backend-URL, sonst funktioniert die Verbindung nicht!
## 🐳 Docker Setup
## 🐳 Docker Setup
...
...
lib/wg-api.ts
View file @
ed053abc
...
@@ -2,12 +2,19 @@
...
@@ -2,12 +2,19 @@
// WG API URL Konfiguration
// WG API URL Konfiguration
// Wenn Frontend und Backend in der gleichen CapRover App laufen:
// Wenn Frontend und Backend in der gleichen CapRover App laufen:
// - Backend ist über localhost erreichbar (gleicher Container) oder
// - Backend läuft als interner Service auf Port 51821
//
//
// Standard: localhost:51821 (wenn beide im gleichen Container)
// Option 1: Backend läuft als separater CapRover Service mit eigener Domain
// Alternative: Wenn Backend als separater Container im Stack läuft, verwende den Service-Namen
// - Setze WG_API_URL auf die externe Backend-URL (z.B. https://wg-easy-backend.corexmanagement.de)
const
WG_API_URL
=
process
.
env
.
WG_API_URL
||
'http://localhost:51821'
//
// Option 2: Backend läuft im gleichen Docker-Netzwerk (nicht empfohlen für CapRover)
// - Verwende Docker Service-Namen oder interne IP
//
// Option 3: Backend läuft auf separatem Port (nur wenn beide im gleichen Container)
// - localhost:51821
//
// WICHTIG: In CapRover sollte das Backend als eigener Service laufen mit eigener Domain!
// Setze WG_API_URL in CapRover als Environment Variable auf die Backend-URL
const
WG_API_URL
=
process
.
env
.
WG_API_URL
||
'https://corex-wg-easy.corexmanagement.de'
const
WG_PASSWORD
=
process
.
env
.
WG_PASSWORD
||
'CoreX2024!Secure#VPN'
const
WG_PASSWORD
=
process
.
env
.
WG_PASSWORD
||
'CoreX2024!Secure#VPN'
interface
WgClient
{
interface
WgClient
{
...
@@ -75,27 +82,36 @@ export class WgApiClient {
...
@@ -75,27 +82,36 @@ export class WgApiClient {
console
.
log
(
`[WG API] Requesting:
${
url
}
`
)
console
.
log
(
`[WG API] Requesting:
${
url
}
`
)
const
response
=
await
fetch
(
url
,
{
try
{
...
options
,
const
response
=
await
fetch
(
url
,
{
headers
,
...
options
,
})
headers
,
})
if
(
!
response
.
ok
)
{
const
errorText
=
await
response
.
text
()
if
(
!
response
.
ok
)
{
// Check if it's HTML (404 page) - means endpoint doesn't exist
const
errorText
=
await
response
.
text
()
if
(
errorText
.
includes
(
'<!DOCTYPE html>'
)
||
errorText
.
includes
(
'<html'
))
{
// Check if it's HTML (404 page) - means endpoint doesn't exist
throw
new
Error
(
`WG API Endpoint not found:
${
endpoint
}
(404). Check if WG_API_URL is correct:
${
this
.
baseUrl
}
`
)
if
(
errorText
.
includes
(
'<!DOCTYPE html>'
)
||
errorText
.
includes
(
'<html'
))
{
throw
new
Error
(
`WG API Endpoint not found:
${
endpoint
}
(404). Check if WG_API_URL is correct:
${
this
.
baseUrl
}
`
)
}
throw
new
Error
(
`WG API Error:
${
response
.
status
}
${
errorText
.
substring
(
0
,
200
)}
`
)
}
}
throw
new
Error
(
`WG API Error:
${
response
.
status
}
${
errorText
.
substring
(
0
,
200
)}
`
)
}
const
contentType
=
response
.
headers
.
get
(
'content-type'
)
const
contentType
=
response
.
headers
.
get
(
'content-type'
)
if
(
contentType
&&
contentType
.
includes
(
'application/json'
))
{
if
(
contentType
&&
contentType
.
includes
(
'application/json'
))
{
return
response
.
json
()
return
response
.
json
()
}
// If not JSON, return as text
return
response
.
text
()
as
unknown
as
T
}
catch
(
error
)
{
// Handle network errors
if
(
error
instanceof
TypeError
&&
error
.
message
.
includes
(
'fetch failed'
))
{
throw
new
Error
(
`Failed to connect to WG API at
${
this
.
baseUrl
}
. Please check if the backend is running and WG_API_URL is correct. Original error:
${
error
.
message
}
`
)
}
// Re-throw other errors
throw
error
}
}
// If not JSON, return as text
return
response
.
text
()
as
unknown
as
T
}
}
async
getStats
():
Promise
<
WgStats
>
{
async
getStats
():
Promise
<
WgStats
>
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment