- Erstelle API-Proxy-Routen für die Kommunikation mit dem externen Backend - Füge API-Konfiguration mit 192.168.0.105:5000 als Backend-URL hinzu - Erstelle Hilfsfunktionen für die externe API-Kommunikation - Füge Skript zum Konfigurieren der Backend-URL hinzu - Aktualisiere Docker-Compose mit der Backend-URL-Umgebungsvariable 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
64 lines
1.8 KiB
Bash
Executable File
64 lines
1.8 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Skript zum Setzen der Backend-URL in der Frontend-Konfiguration
|
|
# Verwendet für die Verbindung zum Backend-Server unter 192.168.0.105:5000
|
|
|
|
# Farbcodes für Ausgabe
|
|
RED='\033[0;31m'
|
|
GREEN='\033[0;32m'
|
|
YELLOW='\033[0;33m'
|
|
BLUE='\033[0;34m'
|
|
NC='\033[0m' # No Color
|
|
|
|
# Funktion zur Ausgabe mit Zeitstempel
|
|
log() {
|
|
echo -e "${BLUE}[$(date +'%Y-%m-%d %H:%M:%S')]${NC} $1"
|
|
}
|
|
|
|
error_log() {
|
|
echo -e "${RED}[$(date +'%Y-%m-%d %H:%M:%S')] FEHLER:${NC} $1" >&2
|
|
}
|
|
|
|
# Definiere Variablen
|
|
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
ENV_FILE="$SCRIPT_DIR/.env.local"
|
|
DEFAULT_BACKEND_URL="http://192.168.0.105:5000"
|
|
|
|
# Falls übergebene Parameter vorhanden sind, Backend-URL anpassen
|
|
if [ -n "$1" ]; then
|
|
BACKEND_URL="$1"
|
|
log "Verwende übergebene Backend-URL: ${BACKEND_URL}"
|
|
else
|
|
BACKEND_URL="$DEFAULT_BACKEND_URL"
|
|
log "Verwende Standard-Backend-URL: ${BACKEND_URL}"
|
|
fi
|
|
|
|
# Erstelle .env.local Datei mit Backend-URL
|
|
log "${YELLOW}Erstelle .env.local Datei...${NC}"
|
|
cat > "$ENV_FILE" << EOL
|
|
# Backend API Konfiguration
|
|
NEXT_PUBLIC_API_URL=${BACKEND_URL}
|
|
|
|
# OAuth Konfiguration (falls nötig)
|
|
OAUTH_CLIENT_ID=client_id
|
|
OAUTH_CLIENT_SECRET=client_secret
|
|
EOL
|
|
|
|
# Überprüfe, ob die Datei erstellt wurde
|
|
if [ -f "$ENV_FILE" ]; then
|
|
log "${GREEN}Erfolgreich .env.local Datei mit Backend-URL erstellt: ${BACKEND_URL}${NC}"
|
|
else
|
|
error_log "Konnte .env.local Datei nicht erstellen."
|
|
exit 1
|
|
fi
|
|
|
|
# Hinweis für Docker-Installation
|
|
log "${YELLOW}WICHTIG: Wenn Sie Docker verwenden, stellen Sie sicher, dass Sie die Umgebungsvariable setzen:${NC}"
|
|
log "NEXT_PUBLIC_API_URL=${BACKEND_URL}"
|
|
log ""
|
|
log "${GREEN}Backend-URL wurde erfolgreich konfiguriert. Nach einem Neustart der Anwendung sollte die Verbindung hergestellt werden.${NC}"
|
|
|
|
# Berechtigungen setzen
|
|
chmod 600 "$ENV_FILE"
|
|
|
|
exit 0 |