diff --git a/backend/.env.example b/backend/.env.example index fcc3870..6589599 100644 --- a/backend/.env.example +++ b/backend/.env.example @@ -29,5 +29,11 @@ MARKETPLACE_COMMISSION=2.5 # CORS_ORIGINS=https://app.saveinmed.com,https://admin.saveinmed.com,http://localhost:3000 CORS_ORIGINS=* +# Swagger Configuration +# Host without scheme (ex: localhost:8214 or api.saveinmed.com) +SWAGGER_HOST=localhost:8214 +# Comma-separated list of schemes shown in Swagger UI selector +SWAGGER_SCHEMES=http,https + # Testing (Optional) # SKIP_DB_TEST=1 diff --git a/backend/cmd/api/main.go b/backend/cmd/api/main.go index fd17a29..0e7f11f 100644 --- a/backend/cmd/api/main.go +++ b/backend/cmd/api/main.go @@ -30,6 +30,12 @@ func main() { // swagger metadata overrides docs.SwaggerInfo.Title = cfg.AppName docs.SwaggerInfo.BasePath = "/" + if cfg.SwaggerHost != "" { + docs.SwaggerInfo.Host = cfg.SwaggerHost + } + if len(cfg.SwaggerSchemes) > 0 { + docs.SwaggerInfo.Schemes = cfg.SwaggerSchemes + } srv, err := server.New(cfg) if err != nil { diff --git a/backend/internal/config/config.go b/backend/internal/config/config.go index d8a8da9..c77a0d5 100644 --- a/backend/internal/config/config.go +++ b/backend/internal/config/config.go @@ -22,6 +22,8 @@ type Config struct { JWTExpiresIn time.Duration PasswordPepper string CORSOrigins []string + SwaggerHost string + SwaggerSchemes []string } // Load reads configuration from environment variables and applies sane defaults @@ -40,6 +42,8 @@ func Load() Config { JWTExpiresIn: getEnvDuration("JWT_EXPIRES_IN", 24*time.Hour), PasswordPepper: getEnv("PASSWORD_PEPPER", ""), CORSOrigins: getEnvStringSlice("CORS_ORIGINS", []string{"*"}), + SwaggerHost: getEnv("SWAGGER_HOST", ""), + SwaggerSchemes: getEnvStringSlice("SWAGGER_SCHEMES", []string{"http"}), } return cfg