diff --git a/src/HeartTrackAPI/Utils/AppBootstrap.cs b/src/HeartTrackAPI/Utils/AppBootstrap.cs index b49cc5f..81213ca 100644 --- a/src/HeartTrackAPI/Utils/AppBootstrap.cs +++ b/src/HeartTrackAPI/Utils/AppBootstrap.cs @@ -189,8 +189,8 @@ public class AppBootstrap(IConfiguration configuration) { options.PreSerializeFilters.Add((swagger, httpReq) => { - if (httpReq.Headers.ContainsKey("X-Forwarded-Host")) - { + //if (httpReq.Headers.ContainsKey("X-Forwarded-Host")) + // { //The httpReq.PathBase and httpReq.Headers["X-Forwarded-Prefix"] is what we need to get the base path. //For some reason, they returning as null/blank. Perhaps this has something to do with how the proxy is configured which we don't have control. //For the time being, the base path is manually set here that corresponds to the APIM API Url Prefix. @@ -198,15 +198,11 @@ public class AppBootstrap(IConfiguration configuration) var basePath = "containers/HeartDev-api"; var serverUrl = $"{httpReq.Scheme}://{httpReq.Headers["X-Forwarded-Host"]}/{basePath}"; - swagger.Servers = new List { new OpenApiServer { Url = serverUrl } }; - } + swagger.Servers = new List { new() { Url = serverUrl }, new() { Url = $"{httpReq.Scheme}://{httpReq.Host.Value}" },new() { Url = $"{httpReq.Scheme}://{httpReq.Host.Value}/{basePath}" } }; + //} }); }); - app.UseSwaggerUI(options => - { - options.RoutePrefix = string.Empty; - options.SwaggerEndpoint("swagger/v1/swagger.json", "My Api (v1)"); - }); + app.UseSwaggerUI(); app.MapSwagger(); /* app.UseSwaggerUI(options => {