fix(swagger): usar URL relativa para doc.json
Corrige o problema do Swagger UI mostrando localhost:8080 em produção. A URL relativa "doc.json" funciona em qualquer ambiente pois o browser resolve automaticamente o caminho completo baseado na URL atual. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
428ceed0cb
commit
c043b2e243
1 changed files with 2 additions and 8 deletions
|
|
@ -2,7 +2,6 @@ package main
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"log"
|
||||
|
||||
"photum-backend/docs"
|
||||
|
|
@ -110,16 +109,11 @@ func main() {
|
|||
docs.SwaggerInfo.Schemes = []string{"http", "https"}
|
||||
}
|
||||
|
||||
// Swagger UI
|
||||
swaggerScheme := "http"
|
||||
if cfg.AppEnv == "production" {
|
||||
swaggerScheme = "https"
|
||||
}
|
||||
swaggerURL := fmt.Sprintf("%s://%s/swagger/doc.json", swaggerScheme, cfg.SwaggerHost)
|
||||
// Swagger UI - usando URL relativa para funcionar em qualquer ambiente
|
||||
r.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler,
|
||||
ginSwagger.PersistAuthorization(true),
|
||||
ginSwagger.DeepLinking(true),
|
||||
ginSwagger.URL(swaggerURL),
|
||||
ginSwagger.URL("doc.json"),
|
||||
))
|
||||
|
||||
// Public Routes
|
||||
|
|
|
|||
Loading…
Reference in a new issue