From 3730ce31521f97e9c81b708408fdc4e5085ac85a Mon Sep 17 00:00:00 2001 From: Wikid82 Date: Sat, 22 Nov 2025 21:47:40 -0500 Subject: [PATCH] fix: normalize domains to lowercase in caddy config, improve error logging --- backend/internal/api/handlers/proxy_host_handler.go | 5 +++-- backend/internal/caddy/config.go | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/backend/internal/api/handlers/proxy_host_handler.go b/backend/internal/api/handlers/proxy_host_handler.go index 39a99446..aa03686c 100644 --- a/backend/internal/api/handlers/proxy_host_handler.go +++ b/backend/internal/api/handlers/proxy_host_handler.go @@ -1,6 +1,7 @@ package handlers import ( + "fmt" "net/http" "github.com/gin-gonic/gin" @@ -70,9 +71,9 @@ func (h *ProxyHostHandler) Create(c *gin.Context) { if h.caddyManager != nil { if err := h.caddyManager.ApplyConfig(c.Request.Context()); err != nil { // Rollback: delete the created host if config application fails + fmt.Printf("Error applying config: %v\n", err) // Log to stdout if deleteErr := h.service.Delete(host.ID); deleteErr != nil { - // Log this critical failure (failed to rollback) - // In a real app, we might want to use a proper logger here + fmt.Printf("Critical: Failed to rollback host %d: %v\n", host.ID, deleteErr) } c.JSON(http.StatusInternalServerError, gin.H{"error": "Failed to apply configuration: " + err.Error()}) return diff --git a/backend/internal/caddy/config.go b/backend/internal/caddy/config.go index cfe47227..c160d4a4 100644 --- a/backend/internal/caddy/config.go +++ b/backend/internal/caddy/config.go @@ -118,6 +118,7 @@ func GenerateConfig(hosts []models.ProxyHost, storageDir string, acmeEmail strin for _, d := range rawDomains { d = strings.TrimSpace(d) + d = strings.ToLower(d) // Normalize to lowercase if d == "" { continue }