From 4e6ab80d581af6da9b1f1ca15ab1e5916c872a26 Mon Sep 17 00:00:00 2001 From: dave Date: Tue, 19 Mar 2024 07:25:43 +0100 Subject: [PATCH] end --- src/HeartTrackAPI/Utils/AppBootstrap.cs | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/src/HeartTrackAPI/Utils/AppBootstrap.cs b/src/HeartTrackAPI/Utils/AppBootstrap.cs index 9c91653..ffc84b9 100644 --- a/src/HeartTrackAPI/Utils/AppBootstrap.cs +++ b/src/HeartTrackAPI/Utils/AppBootstrap.cs @@ -172,7 +172,6 @@ public class AppBootstrap(IConfiguration configuration) public void Configure(WebApplication app, IWebHostEnvironment env) { -// app.UsePathBase("/containers/HeartDev-api"); app.UseHttpsRedirection(); app.MapIdentityApi(); @@ -189,29 +188,24 @@ public class AppBootstrap(IConfiguration configuration) { options.PreSerializeFilters.Add((swagger, httpReq) => { - //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. - //In this case we set it to 'sample-app'. - + if (httpReq.Headers.ContainsKey("X-Forwarded-Host")) + { var basePath = "containers/HeartDev-api"; var serverUrl = $"{httpReq.Scheme}://{httpReq.Headers["X-Forwarded-Host"]}/3{basePath}"; - swagger.Servers = new List { new() { Url = serverUrl }, new() { Url = $"{httpReq.Scheme}://1{httpReq.Host.Value}" },new() { Url = $"{httpReq.Scheme}://2{httpReq.Host.Value}/{basePath}" } }; - //} + swagger.Servers = new List { new() { Url = serverUrl } }; + } }); }); app.UseSwaggerUI(); app.MapSwagger(); -/* app.UseSwaggerUI(options => + app.UseSwaggerUI(options => { foreach (var description in apiVersionDescriptionProvider.ApiVersionDescriptions) { options.SwaggerEndpoint($"/swagger/{description.GroupName}/swagger.json", description.GroupName.ToUpperInvariant()); } - });*/ + }); }