From 3c1ef619b648196c3acae7710c64e1e98ec8dd28 Mon Sep 17 00:00:00 2001 From: Lucca Santangelo <luccasant95@gmail.com> Date: Tue, 17 Nov 2020 19:23:06 -0300 Subject: [PATCH] updates --- Tsi1.Api/Dockerfile | 1 + Tsi1.Api/Tsi1.Api/Startup.cs | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/Tsi1.Api/Dockerfile b/Tsi1.Api/Dockerfile index b10f75c..4292ccf 100644 --- a/Tsi1.Api/Dockerfile +++ b/Tsi1.Api/Dockerfile @@ -20,4 +20,5 @@ WORKDIR /app RUN mkdir /app/StaticFiles COPY --from=build /app/publish . EXPOSE 5000 +VOLUME [ "/app/StaticFiles" ] ENTRYPOINT ["dotnet", "Tsi1.Api.dll"] \ No newline at end of file diff --git a/Tsi1.Api/Tsi1.Api/Startup.cs b/Tsi1.Api/Tsi1.Api/Startup.cs index 369da76..3f9deee 100644 --- a/Tsi1.Api/Tsi1.Api/Startup.cs +++ b/Tsi1.Api/Tsi1.Api/Startup.cs @@ -26,6 +26,7 @@ using Tsi1.BusinessLayer.Services; using Tsi1.BusinessLayer.DataLoad; using Tsi1.DataLayer; using Tsi1.DataLayer.MongoDbConfiguration; +using System.Collections.Generic; namespace Tsi1.Api { @@ -190,7 +191,19 @@ namespace Tsi1.Api app.UseDeveloperExceptionPage(); } - app.UseSwagger(); + app.UseSwagger(c => + { + c.PreSerializeFilters.Add((swaggerDoc, httpRequest) => + { + if (!httpRequest.Headers.ContainsKey("X-Forwarded-Host")) { return; } + + var serverUrl = $"{httpRequest.Headers["X-Forwarded-Proto"]}://" + + $"{httpRequest.Headers["X-Forwarded-Host"]}/" + + $"{httpRequest.Headers["X-Forwarded-Prefix"]}"; + + swaggerDoc.Servers = new List<OpenApiServer>() { new OpenApiServer { Url = serverUrl } }; + }); + }); app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "Tsi1 api V1"); -- GitLab