From 1002a2ec834f6e596b9f968d3e09975871b73f30 Mon Sep 17 00:00:00 2001 From: Tiago Yamamoto Date: Mon, 15 Dec 2025 13:24:37 -0300 Subject: [PATCH] fix(config): auto-detect http/https scheme for swagger --- backend/cmd/api/main.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/backend/cmd/api/main.go b/backend/cmd/api/main.go index d332c98..156959a 100755 --- a/backend/cmd/api/main.go +++ b/backend/cmd/api/main.go @@ -39,12 +39,21 @@ func main() { if apiHost == "" { apiHost = "localhost:8521" } - // Strip protocol schemes if present to ensure clean host for Swagger + + // Detect scheme from env var + schemes := []string{"http", "https"} // default to both + if strings.HasPrefix(apiHost, "https://") { + schemes = []string{"https"} + } else if strings.HasPrefix(apiHost, "http://") { + schemes = []string{"http"} + } + + // Strip protocol schemes to ensure clean host for Swagger apiHost = strings.TrimPrefix(apiHost, "http://") apiHost = strings.TrimPrefix(apiHost, "https://") docs.SwaggerInfo.Host = apiHost - docs.SwaggerInfo.Schemes = []string{"http", "https"} + docs.SwaggerInfo.Schemes = schemes handler := router.NewRouter()