diff --git a/Tsi1.Api/Dockerfile b/Tsi1.Api/Dockerfile index b10f75c87f419081cee0e159cba1b2521e1c6128..4292ccffcaa22d8c287dda3a1c0902ff278c9eb7 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 369da763de4eb9e1b36021dafd89bb2e15651955..3f9deee93729fd9e50277d2ffd69fd8f64aa154d 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");