diff --git a/TelpoKafkaConsole.WebApi/Program.cs b/TelpoKafkaConsole.WebApi/Program.cs index 8ff4b0c..e545660 100644 --- a/TelpoKafkaConsole.WebApi/Program.cs +++ b/TelpoKafkaConsole.WebApi/Program.cs @@ -1,4 +1,5 @@ using Microsoft.Extensions.Configuration; +using Microsoft.OpenApi.Models; using Serilog; using TelpoKafkaConsole.Model; using TelpoKafkaConsole.Service; @@ -47,15 +48,28 @@ namespace TelpoKafkaConsole.WebApi var app = builder.Build(); // Configure the HTTP request pipeline. - //if (app.Environment.IsDevelopment()) - //{ - // app.UseSwagger(); - // app.UseSwaggerUI(); - //} + if (app.Environment.IsDevelopment()) + { + app.UseSwagger(); + + } + else + { + var prefix = "kafkaconsole"; + app.UseSwagger(c => + { + c.PreSerializeFilters.Add((swagger, httpReq) => + { + var scheme = httpReq.Headers.TryGetValue("X-Forwarded-Proto", out var v2) ? v2.ToString() : httpReq.Scheme; + swagger.Servers = new List { new OpenApiServer { Url = $"{scheme}://{httpReq.Host}/{prefix}" } }; + }); + }); + } - app.UseSwagger(); app.UseSwaggerUI(); + + app.UseAuthorization(); app.UseMiddleware();