"""
feat: Update frontend and backend configurations for development environment - Downgrade PyP100 version in requirements.txt for compatibility. - Add new frontend routes for index, login, dashboard, printers, jobs, and profile pages. - Modify docker-compose files for development setup, including environment variables and service names. - Update Caddyfile for local development with Raspberry Pi backend. - Adjust health check route to use updated backend URL. - Enhance setup-backend-url.sh for development environment configuration. """
This commit is contained in:
157
frontend/check-backend-connection.sh
Executable file
157
frontend/check-backend-connection.sh
Executable file
@@ -0,0 +1,157 @@
|
||||
#!/bin/bash
|
||||
|
||||
# 🔍 MYP Frontend - Backend-Verbindung prüfen
|
||||
# Entwicklungsumgebung - Überprüft Verbindung zum Raspberry Pi Backend auf 192.168.0.105:5000
|
||||
|
||||
set -e
|
||||
|
||||
# Farben für Terminal-Ausgabe
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
# Funktionen
|
||||
log_info() {
|
||||
echo -e "${BLUE}[INFO]${NC} $1"
|
||||
}
|
||||
|
||||
log_success() {
|
||||
echo -e "${GREEN}[SUCCESS]${NC} $1"
|
||||
}
|
||||
|
||||
log_warning() {
|
||||
echo -e "${YELLOW}[WARNING]${NC} $1"
|
||||
}
|
||||
|
||||
log_error() {
|
||||
echo -e "${RED}[ERROR]${NC} $1"
|
||||
}
|
||||
|
||||
# Arbeitsverzeichnis setzen
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
cd "$SCRIPT_DIR"
|
||||
|
||||
echo "🔍 MYP Frontend - Backend-Verbindung wird überprüft..."
|
||||
echo "🍓 Entwicklungsumgebung - Raspberry Pi Backend"
|
||||
echo "=================================================="
|
||||
|
||||
# Backend-URL definieren (Hardcoded für Raspberry Pi)
|
||||
BACKEND_URL="http://192.168.0.105:5000"
|
||||
BACKEND_API_URL="$BACKEND_URL/api"
|
||||
RASPBERRY_PI_HOST="192.168.0.105"
|
||||
|
||||
log_info "Ziel-Backend: $BACKEND_URL (Raspberry Pi)"
|
||||
echo ""
|
||||
|
||||
# 1. Netzwerk-Konnektivität zum Raspberry Pi prüfen
|
||||
log_info "1. Prüfe Netzwerk-Konnektivität zum Raspberry Pi ($RASPBERRY_PI_HOST)..."
|
||||
if ping -c 1 -W 3 $RASPBERRY_PI_HOST >/dev/null 2>&1; then
|
||||
log_success "✓ Ping zum Raspberry Pi erfolgreich"
|
||||
else
|
||||
log_error "✗ Ping zum Raspberry Pi fehlgeschlagen"
|
||||
log_error " Stellen Sie sicher, dass der Raspberry Pi erreichbar ist"
|
||||
log_error " Prüfen Sie die Netzwerkverbindung und IP-Adresse"
|
||||
fi
|
||||
|
||||
# 2. Backend-Service auf Raspberry Pi prüfen
|
||||
log_info "2. Prüfe Backend-Service auf Raspberry Pi Port 5000..."
|
||||
if curl -f --connect-timeout 5 "$BACKEND_URL/health" >/dev/null 2>&1; then
|
||||
log_success "✓ Raspberry Pi Backend-Health-Check erfolgreich"
|
||||
elif curl -f --connect-timeout 5 "$BACKEND_URL" >/dev/null 2>&1; then
|
||||
log_warning "⚠ Raspberry Pi Backend erreichbar, aber kein Health-Endpoint"
|
||||
else
|
||||
log_error "✗ Raspberry Pi Backend-Service nicht erreichbar"
|
||||
log_error " Stellen Sie sicher, dass das Backend auf dem Raspberry Pi läuft"
|
||||
log_error " Prüfen Sie: ssh pi@$RASPBERRY_PI_HOST 'sudo systemctl status myp-backend'"
|
||||
fi
|
||||
|
||||
# 3. API-Endpunkte auf Raspberry Pi prüfen
|
||||
log_info "3. Prüfe Raspberry Pi Backend-API-Endpunkte..."
|
||||
for endpoint in "printers" "jobs" "users"; do
|
||||
if curl -f --connect-timeout 5 "$BACKEND_API_URL/$endpoint" >/dev/null 2>&1; then
|
||||
log_success "✓ API-Endpunkt /$endpoint auf Raspberry Pi erreichbar"
|
||||
else
|
||||
log_warning "⚠ API-Endpunkt /$endpoint auf Raspberry Pi nicht erreichbar"
|
||||
fi
|
||||
done
|
||||
|
||||
echo ""
|
||||
|
||||
# 4. Frontend-Konfigurationsdateien für Entwicklung prüfen
|
||||
log_info "4. Prüfe Frontend-Konfigurationsdateien (Entwicklungsumgebung)..."
|
||||
|
||||
# .env.local prüfen
|
||||
if [ -f ".env.local" ]; then
|
||||
if grep -q "NEXT_PUBLIC_API_URL=http://192.168.0.105:5000" .env.local; then
|
||||
log_success "✓ .env.local korrekt für Raspberry Pi konfiguriert"
|
||||
else
|
||||
log_warning "⚠ .env.local existiert, aber Raspberry Pi Backend-URL ist falsch"
|
||||
log_info " Führen Sie './setup-backend-url.sh' aus"
|
||||
fi
|
||||
else
|
||||
log_warning "⚠ .env.local nicht gefunden"
|
||||
log_info " Führen Sie './setup-backend-url.sh' aus"
|
||||
fi
|
||||
|
||||
# env.frontend prüfen
|
||||
if grep -q "NODE_ENV=development" env.frontend && grep -q "NEXT_PUBLIC_API_URL=http://192.168.0.105:5000" env.frontend; then
|
||||
log_success "✓ env.frontend korrekt für Entwicklungsumgebung konfiguriert"
|
||||
else
|
||||
log_error "✗ env.frontend nicht für Entwicklungsumgebung konfiguriert"
|
||||
fi
|
||||
|
||||
# api-config.ts prüfen
|
||||
if grep -q 'API_BASE_URL = process.env.NEXT_PUBLIC_API_URL || "http://192.168.0.105:5000"' src/utils/api-config.ts; then
|
||||
log_success "✓ api-config.ts korrekt für Raspberry Pi konfiguriert"
|
||||
else
|
||||
log_error "✗ api-config.ts hat falsche Standard-URL"
|
||||
fi
|
||||
|
||||
# Docker-Compose-Dateien für Entwicklung prüfen
|
||||
if grep -q "NODE_ENV=development" docker-compose.yml && grep -q "NEXT_PUBLIC_API_URL=http://192.168.0.105:5000" docker-compose.yml; then
|
||||
log_success "✓ docker-compose.yml korrekt für Entwicklungsumgebung konfiguriert"
|
||||
else
|
||||
log_warning "⚠ docker-compose.yml nicht für Entwicklungsumgebung konfiguriert"
|
||||
fi
|
||||
|
||||
# Caddy-Konfiguration für Entwicklung prüfen
|
||||
if grep -q "reverse_proxy 192.168.0.105:5000" docker/caddy/Caddyfile && grep -q "localhost" docker/caddy/Caddyfile; then
|
||||
log_success "✓ Caddy-Konfiguration korrekt für Entwicklungsumgebung"
|
||||
else
|
||||
log_error "✗ Caddy-Konfiguration nicht für Entwicklungsumgebung konfiguriert"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
|
||||
# 5. Zusammenfassung und Empfehlungen für Entwicklungsumgebung
|
||||
log_info "5. Zusammenfassung und Empfehlungen (Entwicklungsumgebung):"
|
||||
echo ""
|
||||
|
||||
if ping -c 1 -W 3 $RASPBERRY_PI_HOST >/dev/null 2>&1 && curl -f --connect-timeout 5 "$BACKEND_URL" >/dev/null 2>&1; then
|
||||
log_success "🎉 Raspberry Pi Backend ist erreichbar und läuft!"
|
||||
echo ""
|
||||
log_info "Nächste Schritte (Entwicklung):"
|
||||
echo " 1. Frontend starten: ./start-frontend-server.sh"
|
||||
echo " 2. Frontend testen: http://localhost:3000"
|
||||
echo " 3. Health-Check: http://localhost:3000/health"
|
||||
echo " 4. Backend-Health: http://localhost:3000/backend-health"
|
||||
else
|
||||
log_error "❌ Raspberry Pi Backend ist nicht erreichbar!"
|
||||
echo ""
|
||||
log_info "Fehlerbehebung (Entwicklungsumgebung):"
|
||||
echo " 1. Prüfen Sie, ob der Raspberry Pi ($RASPBERRY_PI_HOST) läuft"
|
||||
echo " 2. SSH zum Raspberry Pi: ssh pi@$RASPBERRY_PI_HOST"
|
||||
echo " 3. Backend-Status prüfen: sudo systemctl status myp-backend"
|
||||
echo " 4. Backend-Logs prüfen: sudo journalctl -u myp-backend -f"
|
||||
echo " 5. Netzwerk-Konnektivität prüfen"
|
||||
echo " 6. Firewall-Einstellungen auf Raspberry Pi prüfen"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
log_info "Debug-Tools:"
|
||||
echo " - Debug-Server: ./debug-server/start-debug-server.sh"
|
||||
echo " - Backend direkt: curl http://192.168.0.105:5000/health"
|
||||
echo " - SSH zum Raspberry Pi: ssh pi@192.168.0.105"
|
||||
echo "=================================================="
|
@@ -1,5 +1,5 @@
|
||||
# 🎨 MYP Frontend - Standalone Server Konfiguration
|
||||
# Frontend-Service als vollständig unabhängiger Server
|
||||
# 🎨 MYP Frontend - Entwicklungsumgebung Konfiguration
|
||||
# Frontend-Service für die Entwicklung mit Raspberry Pi Backend
|
||||
|
||||
version: '3.8'
|
||||
|
||||
@@ -8,33 +8,38 @@ services:
|
||||
frontend:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
dockerfile: Dockerfile.dev
|
||||
args:
|
||||
- BUILDKIT_INLINE_CACHE=1
|
||||
- NODE_ENV=${NODE_ENV:-production}
|
||||
image: myp/frontend:latest
|
||||
container_name: myp-frontend-standalone
|
||||
- NODE_ENV=development
|
||||
image: myp/frontend:dev
|
||||
container_name: myp-frontend-dev
|
||||
restart: unless-stopped
|
||||
|
||||
environment:
|
||||
- NODE_ENV=${NODE_ENV:-production}
|
||||
- NODE_ENV=development
|
||||
- NEXT_TELEMETRY_DISABLED=1
|
||||
|
||||
# Backend API Konfiguration
|
||||
- NEXT_PUBLIC_API_URL=${BACKEND_API_URL:-http://localhost:5000/api}
|
||||
- NEXT_PUBLIC_BACKEND_HOST=${BACKEND_HOST:-localhost:5000}
|
||||
# Backend API Konfiguration (Raspberry Pi)
|
||||
- NEXT_PUBLIC_API_URL=http://192.168.0.105:5000
|
||||
- NEXT_PUBLIC_BACKEND_HOST=192.168.0.105:5000
|
||||
|
||||
# Frontend Server
|
||||
- PORT=3000
|
||||
- HOSTNAME=0.0.0.0
|
||||
|
||||
# Auth Konfiguration
|
||||
- NEXTAUTH_URL=${FRONTEND_URL:-http://localhost:3000}
|
||||
- NEXTAUTH_SECRET=${NEXTAUTH_SECRET:-frontend-auth-secret}
|
||||
# Auth Konfiguration (Entwicklung)
|
||||
- NEXTAUTH_URL=http://localhost:3000
|
||||
- NEXTAUTH_SECRET=dev-frontend-auth-secret
|
||||
|
||||
# Debug-Einstellungen
|
||||
- DEBUG=true
|
||||
- NEXT_DEBUG=true
|
||||
|
||||
volumes:
|
||||
- frontend_data:/app/.next
|
||||
- frontend_cache:/app/.next/cache
|
||||
- .:/app
|
||||
- /app/node_modules
|
||||
- /app/.next
|
||||
- ./public:/app/public:ro
|
||||
|
||||
ports:
|
||||
@@ -43,6 +48,9 @@ services:
|
||||
networks:
|
||||
- frontend-network
|
||||
|
||||
extra_hosts:
|
||||
- "raspberrypi:192.168.0.105"
|
||||
|
||||
healthcheck:
|
||||
test: ["CMD", "curl", "-f", "http://localhost:3000/health"]
|
||||
interval: 30s
|
||||
@@ -52,8 +60,8 @@ services:
|
||||
|
||||
labels:
|
||||
- "service.type=frontend"
|
||||
- "service.name=myp-frontend"
|
||||
- "service.environment=${NODE_ENV:-production}"
|
||||
- "service.name=myp-frontend-dev"
|
||||
- "service.environment=development"
|
||||
|
||||
# === FRONTEND CACHE (Optional: Redis für Session Management) ===
|
||||
frontend-cache:
|
||||
|
@@ -5,25 +5,34 @@ services:
|
||||
frontend:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
container_name: myp-rp
|
||||
dockerfile: Dockerfile.dev
|
||||
container_name: myp-rp-dev
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
- NODE_ENV=production
|
||||
- NEXT_PUBLIC_API_URL=https://m040tbaraspi001.de040.corpintra.net/api
|
||||
- NODE_ENV=development
|
||||
- NEXT_PUBLIC_API_URL=http://192.168.0.105:5000
|
||||
- NEXT_PUBLIC_BACKEND_HOST=192.168.0.105:5000
|
||||
- DEBUG=true
|
||||
- NEXT_DEBUG=true
|
||||
volumes:
|
||||
- .:/app
|
||||
- /app/node_modules
|
||||
- /app/.next
|
||||
ports:
|
||||
- "3000:3000"
|
||||
networks:
|
||||
- myp-network
|
||||
healthcheck:
|
||||
test: ["CMD", "wget", "--spider", "http://localhost:3000/api/health"]
|
||||
test: ["CMD", "wget", "--spider", "http://localhost:3000/health"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
start_period: 40s
|
||||
|
||||
# Caddy Proxy
|
||||
# Caddy Proxy (Entwicklung)
|
||||
caddy:
|
||||
image: caddy:2.7-alpine
|
||||
container_name: myp-caddy
|
||||
container_name: myp-caddy-dev
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "80:80"
|
||||
@@ -36,9 +45,10 @@ services:
|
||||
- myp-network
|
||||
extra_hosts:
|
||||
- "host.docker.internal:host-gateway"
|
||||
- "raspberrypi:192.168.0.105"
|
||||
environment:
|
||||
- CADDY_HOST=53.37.211.254
|
||||
- CADDY_DOMAIN=m040tbaraspi001.de040.corpintra.net
|
||||
- CADDY_HOST=localhost
|
||||
- CADDY_DOMAIN=localhost
|
||||
cap_add:
|
||||
- NET_ADMIN
|
||||
|
||||
|
@@ -2,51 +2,54 @@
|
||||
debug
|
||||
}
|
||||
|
||||
# Hauptdomain und IP-Adresse für die Anwendung
|
||||
53.37.211.254, m040tbaraspi001.de040.corpintra.net, m040tbaraspi001, de040.corpintra.net, localhost {
|
||||
# API Anfragen zum Backend weiterleiten
|
||||
# Entwicklungsumgebung - Localhost und Raspberry Pi Backend
|
||||
localhost, 127.0.0.1 {
|
||||
# API Anfragen zum Raspberry Pi Backend weiterleiten
|
||||
@api {
|
||||
path /api/* /health
|
||||
}
|
||||
handle @api {
|
||||
uri strip_prefix /api
|
||||
reverse_proxy 192.168.0.5:5000
|
||||
reverse_proxy 192.168.0.105:5000 {
|
||||
header_up Host {upstream_hostport}
|
||||
header_up X-Real-IP {remote_host}
|
||||
header_up X-Forwarded-For {remote_host}
|
||||
header_up X-Forwarded-Proto {scheme}
|
||||
}
|
||||
}
|
||||
|
||||
# Alle anderen Anfragen zum Frontend weiterleiten
|
||||
handle {
|
||||
reverse_proxy myp-rp:3000
|
||||
reverse_proxy myp-rp-dev:3000 {
|
||||
header_up Host {upstream_hostport}
|
||||
header_up X-Real-IP {remote_host}
|
||||
header_up X-Forwarded-For {remote_host}
|
||||
header_up X-Forwarded-Proto {scheme}
|
||||
}
|
||||
}
|
||||
|
||||
tls internal {
|
||||
on_demand
|
||||
}
|
||||
# TLS für Entwicklung deaktiviert
|
||||
tls off
|
||||
|
||||
# Erlaube HTTP -> HTTPS Redirects für OAuth
|
||||
# OAuth Callbacks für Entwicklung
|
||||
@oauth path /auth/login/callback*
|
||||
handle @oauth {
|
||||
header Cache-Control "no-cache"
|
||||
reverse_proxy myp-rp:3000
|
||||
reverse_proxy myp-rp-dev:3000
|
||||
}
|
||||
|
||||
# Allgemeine Header für Sicherheit und Caching
|
||||
# Entwicklungsfreundliche Header
|
||||
header {
|
||||
# Sicherheitsheader
|
||||
Strict-Transport-Security "max-age=31536000; includeSubDomains"
|
||||
# Weniger restriktive Sicherheitsheader für Entwicklung
|
||||
X-Content-Type-Options "nosniff"
|
||||
X-Frame-Options "SAMEORIGIN"
|
||||
Referrer-Policy "strict-origin-when-cross-origin"
|
||||
|
||||
# Cache-Control für statische Assets
|
||||
@static {
|
||||
path *.js *.css *.png *.jpg *.svg *.ico *.woff *.woff2
|
||||
}
|
||||
header @static Cache-Control "public, max-age=86400"
|
||||
# Keine Caches für Entwicklung
|
||||
Cache-Control "no-store, no-cache, must-revalidate"
|
||||
|
||||
# Keine Caches für dynamische Inhalte
|
||||
@dynamic {
|
||||
not path *.js *.css *.png *.jpg *.svg *.ico *.woff *.woff2
|
||||
}
|
||||
header @dynamic Cache-Control "no-store, no-cache, must-revalidate"
|
||||
# CORS für Entwicklung
|
||||
Access-Control-Allow-Origin "*"
|
||||
Access-Control-Allow-Methods "GET, POST, PUT, DELETE, OPTIONS"
|
||||
Access-Control-Allow-Headers "Content-Type, Authorization"
|
||||
}
|
||||
}
|
@@ -1,8 +1,8 @@
|
||||
# 🎨 MYP Frontend - Standalone Server Konfiguration
|
||||
# Umgebungsvariablen ausschließlich für den Frontend-Server
|
||||
# 🎨 MYP Frontend - Entwicklungsumgebung Konfiguration
|
||||
# Umgebungsvariablen für die Verbindung zum Raspberry Pi Backend
|
||||
|
||||
# === NODE.JS KONFIGURATION ===
|
||||
NODE_ENV=production
|
||||
NODE_ENV=development
|
||||
NEXT_TELEMETRY_DISABLED=1
|
||||
|
||||
# === FRONTEND SERVER ===
|
||||
@@ -11,18 +11,18 @@ HOSTNAME=0.0.0.0
|
||||
FRONTEND_URL=http://localhost:3000
|
||||
|
||||
# === BACKEND API KONFIGURATION ===
|
||||
# Backend-Server Verbindung (HTTP)
|
||||
BACKEND_API_URL=http://localhost:5000/api
|
||||
BACKEND_HOST=localhost:5000
|
||||
NEXT_PUBLIC_API_URL=http://localhost:5000/api
|
||||
NEXT_PUBLIC_BACKEND_HOST=localhost:5000
|
||||
# Backend-Server Verbindung (Raspberry Pi)
|
||||
BACKEND_API_URL=http://192.168.0.105:5000/api
|
||||
BACKEND_HOST=192.168.0.105:5000
|
||||
NEXT_PUBLIC_API_URL=http://192.168.0.105:5000
|
||||
NEXT_PUBLIC_BACKEND_HOST=192.168.0.105:5000
|
||||
|
||||
# === AUTHENTIFIZIERUNG ===
|
||||
NEXTAUTH_URL=http://localhost:3000
|
||||
NEXTAUTH_SECRET=frontend-auth-secret-2024
|
||||
JWT_SECRET=frontend-jwt-secret-2024
|
||||
NEXTAUTH_SECRET=dev-frontend-auth-secret-2024
|
||||
JWT_SECRET=dev-frontend-jwt-secret-2024
|
||||
|
||||
# OAuth Provider (falls verwendet)
|
||||
# OAuth Provider (Entwicklung)
|
||||
GOOGLE_CLIENT_ID=
|
||||
GOOGLE_CLIENT_SECRET=
|
||||
MICROSOFT_CLIENT_ID=
|
||||
@@ -35,7 +35,7 @@ FRONTEND_DB_PATH=db/frontend.db
|
||||
|
||||
# === CACHE KONFIGURATION ===
|
||||
# Frontend-spezifischer Redis Cache (separater Port!)
|
||||
FRONTEND_REDIS_PASSWORD=frontend_cache_password
|
||||
FRONTEND_REDIS_PASSWORD=dev_frontend_cache_password
|
||||
FRONTEND_REDIS_HOST=localhost
|
||||
FRONTEND_REDIS_PORT=6380
|
||||
FRONTEND_REDIS_DB=1
|
||||
@@ -45,19 +45,19 @@ CDN_URL=http://localhost:8080
|
||||
ASSETS_URL=http://localhost:8080/static
|
||||
|
||||
# === SICHERHEIT ===
|
||||
# CSP (Content Security Policy)
|
||||
# CSP (Content Security Policy) - Entwicklung
|
||||
CSP_SCRIPT_SRC="'self' 'unsafe-inline' 'unsafe-eval'"
|
||||
CSP_STYLE_SRC="'self' 'unsafe-inline'"
|
||||
CSP_IMG_SRC="'self' data: https:"
|
||||
CSP_CONNECT_SRC="'self' ws: wss: http://localhost:5000"
|
||||
CSP_CONNECT_SRC="'self' ws: wss: http://192.168.0.105:5000 http://localhost:5000"
|
||||
|
||||
# === MONITORING ===
|
||||
ANALYTICS_ENABLED=true
|
||||
ANALYTICS_ENABLED=false
|
||||
ERROR_REPORTING_ENABLED=true
|
||||
|
||||
# === ENTWICKLUNG ===
|
||||
DEBUG=false
|
||||
NEXT_DEBUG=false
|
||||
DEBUG=true
|
||||
NEXT_DEBUG=true
|
||||
|
||||
# === BUILD KONFIGURATION ===
|
||||
ANALYZE=false
|
||||
|
@@ -1,5 +1,6 @@
|
||||
/** @type {import('next').NextConfig} */
|
||||
const nextConfig = {
|
||||
// Entwicklungsumgebung - weniger restriktive CORS
|
||||
async headers() {
|
||||
return [
|
||||
{
|
||||
@@ -7,7 +8,7 @@ const nextConfig = {
|
||||
headers: [
|
||||
{
|
||||
key: "Access-Control-Allow-Origin",
|
||||
value: "m040tbaraspi001.de040.corpintra.net",
|
||||
value: "*",
|
||||
},
|
||||
{
|
||||
key: "Access-Control-Allow-Methods",
|
||||
@@ -21,6 +22,30 @@ const nextConfig = {
|
||||
},
|
||||
];
|
||||
},
|
||||
// Rewrites für Backend-API-Aufrufe zum Raspberry Pi
|
||||
async rewrites() {
|
||||
return [
|
||||
{
|
||||
source: '/api/backend/:path*',
|
||||
destination: 'http://192.168.0.105:5000/api/:path*',
|
||||
},
|
||||
// Direkter Proxy für Health-Checks
|
||||
{
|
||||
source: '/backend-health',
|
||||
destination: 'http://192.168.0.105:5000/health',
|
||||
},
|
||||
];
|
||||
},
|
||||
// Entwicklungseinstellungen
|
||||
experimental: {
|
||||
serverComponentsExternalPackages: [],
|
||||
},
|
||||
// Logging für Entwicklung
|
||||
logging: {
|
||||
fetches: {
|
||||
fullUrl: true,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export default nextConfig;
|
||||
|
66
frontend/setup-backend-url.sh
Normal file → Executable file
66
frontend/setup-backend-url.sh
Normal file → Executable file
@@ -1,7 +1,7 @@
|
||||
#!/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
|
||||
# Entwicklungsumgebung - Raspberry Pi Backend auf 192.168.0.105:5000
|
||||
|
||||
# Farbcodes für Ausgabe
|
||||
RED='\033[0;31m'
|
||||
@@ -22,59 +22,57 @@ error_log() {
|
||||
# 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"
|
||||
# Hardcoded für Entwicklungsumgebung - Raspberry Pi Backend
|
||||
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
|
||||
log "Entwicklungsumgebung - Raspberry Pi Backend: ${BACKEND_URL}"
|
||||
|
||||
# Bestimme den Hostnamen für OAuth
|
||||
HOSTNAME=$(hostname)
|
||||
if [[ "$HOSTNAME" == *"m040tbaraspi001"* ]] || [[ "$HOSTNAME" == *"corpintra"* ]]; then
|
||||
FRONTEND_HOSTNAME="m040tbaraspi001.de040.corpintra.net"
|
||||
OAUTH_URL="http://m040tbaraspi001.de040.corpintra.net/auth/login/callback"
|
||||
log "Erkannt: Unternehmens-Hostname: $FRONTEND_HOSTNAME"
|
||||
else
|
||||
FRONTEND_HOSTNAME="$HOSTNAME"
|
||||
OAUTH_URL="http://$HOSTNAME:3000/auth/login/callback"
|
||||
log "Lokaler Hostname: $FRONTEND_HOSTNAME"
|
||||
fi
|
||||
# Hostname für OAuth (Entwicklung)
|
||||
FRONTEND_HOSTNAME="localhost"
|
||||
OAUTH_URL="http://localhost:3000/auth/login/callback"
|
||||
log "Frontend-Hostname (Entwicklung): $FRONTEND_HOSTNAME"
|
||||
|
||||
# Erstelle .env.local Datei mit Backend-URL
|
||||
log "${YELLOW}Erstelle .env.local Datei...${NC}"
|
||||
log "${YELLOW}Erstelle .env.local Datei für Entwicklungsumgebung...${NC}"
|
||||
cat > "$ENV_FILE" << EOL
|
||||
# Backend API Konfiguration
|
||||
# Backend API Konfiguration - Raspberry Pi (Entwicklung)
|
||||
NEXT_PUBLIC_API_URL=${BACKEND_URL}
|
||||
|
||||
# Frontend-URL für OAuth Callback
|
||||
NEXT_PUBLIC_FRONTEND_URL=http://${FRONTEND_HOSTNAME}
|
||||
# Frontend-URL für OAuth Callback (Entwicklung)
|
||||
NEXT_PUBLIC_FRONTEND_URL=http://${FRONTEND_HOSTNAME}:3000
|
||||
|
||||
# Explizite OAuth Callback URL für GitHub
|
||||
# Explizite OAuth Callback URL für GitHub (Entwicklung)
|
||||
NEXT_PUBLIC_OAUTH_CALLBACK_URL=${OAUTH_URL}
|
||||
|
||||
# OAuth Konfiguration (falls nötig)
|
||||
OAUTH_CLIENT_ID=client_id
|
||||
OAUTH_CLIENT_SECRET=client_secret
|
||||
# Entwicklungsumgebung
|
||||
NODE_ENV=development
|
||||
DEBUG=true
|
||||
NEXT_DEBUG=true
|
||||
|
||||
# OAuth Konfiguration (Entwicklung)
|
||||
OAUTH_CLIENT_ID=dev_client_id
|
||||
OAUTH_CLIENT_SECRET=dev_client_secret
|
||||
|
||||
# Raspberry Pi Backend Host
|
||||
NEXT_PUBLIC_BACKEND_HOST=192.168.0.105:5000
|
||||
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}"
|
||||
log "${GREEN}Erfolgreich .env.local Datei für Entwicklungsumgebung 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}"
|
||||
# Hinweis für Entwicklungsumgebung
|
||||
log "${YELLOW}ENTWICKLUNGSUMGEBUNG KONFIGURIERT:${NC}"
|
||||
log "Backend (Raspberry Pi): ${BACKEND_URL}"
|
||||
log "Frontend: http://localhost:3000"
|
||||
log "OAuth Callback: ${OAUTH_URL}"
|
||||
log ""
|
||||
log "${GREEN}Backend-URL wurde erfolgreich konfiguriert. Nach einem Neustart der Anwendung sollte die Verbindung hergestellt werden.${NC}"
|
||||
log "${GREEN}Backend-URL wurde erfolgreich für die Entwicklungsumgebung konfiguriert.${NC}"
|
||||
log "${GREEN}Das Frontend verbindet sich jetzt mit dem Raspberry Pi Backend.${NC}"
|
||||
|
||||
# Berechtigungen setzen
|
||||
chmod 600 "$ENV_FILE"
|
||||
|
@@ -7,7 +7,7 @@ import { NextRequest, NextResponse } from 'next/server';
|
||||
export async function GET(request: NextRequest) {
|
||||
try {
|
||||
// Prüfe Backend-Verbindung
|
||||
const backendUrl = process.env.BACKEND_API_URL || 'http://localhost:5000';
|
||||
const backendUrl = process.env.NEXT_PUBLIC_API_URL || 'http://192.168.0.105:5000';
|
||||
let backendStatus = 'unknown';
|
||||
|
||||
try {
|
||||
|
Reference in New Issue
Block a user