try
continuous-integration/drone/push Build is passing Details

pull/10/head
David D'ALMEIDA 1 year ago
parent ecc4079700
commit 997c06b693

@ -172,6 +172,7 @@ public class AppBootstrap(IConfiguration configuration)
public void Configure(WebApplication app, IWebHostEnvironment env) public void Configure(WebApplication app, IWebHostEnvironment env)
{ {
// app.UsePathBase("/containers/HeartDev-api");
app.UseHttpsRedirection(); app.UseHttpsRedirection();
app.MapIdentityApi<IdentityUser>(); app.MapIdentityApi<IdentityUser>();
@ -184,8 +185,28 @@ public class AppBootstrap(IConfiguration configuration)
if (true) if (true)
{ {
var apiVersionDescriptionProvider = app.Services.GetRequiredService<IApiVersionDescriptionProvider>(); var apiVersionDescriptionProvider = app.Services.GetRequiredService<IApiVersionDescriptionProvider>();
app.UseSwagger(); app.UseSwagger(options =>
app.UseSwaggerUI(); {
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'.
var basePath = "/containers/HeartDev-api";
var serverUrl = $"{httpReq.Scheme}://{httpReq.Headers["X-Forwarded-Host"]}/{basePath}";
swagger.Servers = new List<OpenApiServer> { new OpenApiServer { Url = serverUrl } };
}
});
});
app.UseSwaggerUI(options =>
{
options.RoutePrefix = string.Empty;
options.SwaggerEndpoint("swagger/v1/swagger.json", "My Api (v1)");
});
app.MapSwagger(); app.MapSwagger();
/* app.UseSwaggerUI(options => /* app.UseSwaggerUI(options =>
{ {

Loading…
Cancel
Save