ADD: added dockerfiles and a logger for the backend

This commit is contained in:
hwinkel
2025-12-15 13:30:41 +01:00
parent 7ec17e1e8b
commit 435ad8e6e6
12 changed files with 183 additions and 19 deletions

View File

@@ -1,12 +1,10 @@
package server
import (
"fmt"
"log"
"os"
"studia/internal/auth"
"studia/internal/config"
"studia/internal/database"
"studia/internal/logger"
"time"
"github.com/gin-contrib/cors"
@@ -21,18 +19,18 @@ func StartServer(cfg *config.Config) {
// 2. CORS-Konfiguration
// Lese die Frontend-URL aus den Umgebungsvariablen
frontendURL := os.Getenv("FRONTEND_URL")
// frontendURL := os.Getenv("FRONTEND_URL")
// Lokaler Fallback (wichtig für die Entwicklung)
allowedOrigins := []string{
"http://localhost:5173", // Gängiger Vite-Dev-Port
}
if frontendURL != "" {
allowedOrigins = append(allowedOrigins, frontendURL)
fmt.Printf("CORS: Erlaubte Produktiv-URL hinzugefügt: %s\n", frontendURL)
if cfg.FrontendURL != "" {
allowedOrigins = append(allowedOrigins, cfg.FrontendURL)
logger.Log.Printf("CORS: Erlaubte Produktiv-URL hinzugefügt: %s\n", cfg.FrontendURL)
} else {
log.Println("ACHTUNG: FRONTEND_URL fehlt in den Umgebungsvariablen. Nur lokale URLs erlaubt.")
logger.Log.Error().Msg("ACHTUNG: FRONTEND_URL fehlt in den Umgebungsvariablen. Nur lokale URLs erlaubt.")
}
// CORS