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 (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"photum-backend/docs"
|
"photum-backend/docs"
|
||||||
|
|
@ -110,16 +109,11 @@ func main() {
|
||||||
docs.SwaggerInfo.Schemes = []string{"http", "https"}
|
docs.SwaggerInfo.Schemes = []string{"http", "https"}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Swagger UI
|
// Swagger UI - usando URL relativa para funcionar em qualquer ambiente
|
||||||
swaggerScheme := "http"
|
|
||||||
if cfg.AppEnv == "production" {
|
|
||||||
swaggerScheme = "https"
|
|
||||||
}
|
|
||||||
swaggerURL := fmt.Sprintf("%s://%s/swagger/doc.json", swaggerScheme, cfg.SwaggerHost)
|
|
||||||
r.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler,
|
r.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler,
|
||||||
ginSwagger.PersistAuthorization(true),
|
ginSwagger.PersistAuthorization(true),
|
||||||
ginSwagger.DeepLinking(true),
|
ginSwagger.DeepLinking(true),
|
||||||
ginSwagger.URL(swaggerURL),
|
ginSwagger.URL("doc.json"),
|
||||||
))
|
))
|
||||||
|
|
||||||
// Public Routes
|
// Public Routes
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue