diff --git a/Program.cs b/Program.cs index dd6d069..55cb27b 100644 --- a/Program.cs +++ b/Program.cs @@ -92,6 +92,13 @@ app.UseMiddleware(); app.UseSwagger(options => { options.RouteTemplate = "docs/{documentName}/swagger.json"; + // Advertise the request path base (e.g. /apps/idoklad behind the portal proxy) as the + // OpenAPI server so Swagger UI "Try it out" targets {pathBase}/contacts, not the host root. + options.PreSerializeFilters.Add((swaggerDoc, httpReq) => + { + var basePath = httpReq.PathBase.HasValue ? httpReq.PathBase.Value : "/"; + swaggerDoc.Servers = new List { new() { Url = basePath } }; + }); }); app.UseSwaggerUI(options => {