diff --git a/Server/Program.cs b/Server/Program.cs index 40e5f6815..9f9b2be7f 100644 --- a/Server/Program.cs +++ b/Server/Program.cs @@ -111,17 +111,20 @@ services.AddServerSideBlazor(); services.AddScoped>(); services.AddDatabaseDeveloperPageExceptionFilter(); -services.AddHttpLogging(options => +if (bool.TryParse(configuration["ApplicationOptions:UseHttpLogging"], out var useHttpLogging) && + useHttpLogging) { - options.RequestHeaders.Add("X-Forwarded-For"); - options.RequestHeaders.Add("X-Forwarded-Proto"); - options.RequestHeaders.Add("X-Forwarded-Host"); - options.RequestHeaders.Add("X-Original-For"); - options.RequestHeaders.Add("X-Original-Proto"); - options.RequestHeaders.Add("X-Original-Host"); - options.RequestHeaders.Add("Host"); -}); - + services.AddHttpLogging(options => + { + options.RequestHeaders.Add("X-Forwarded-For"); + options.RequestHeaders.Add("X-Forwarded-Proto"); + options.RequestHeaders.Add("X-Forwarded-Host"); + options.RequestHeaders.Add("X-Original-For"); + options.RequestHeaders.Add("X-Original-Proto"); + options.RequestHeaders.Add("X-Original-Host"); + options.RequestHeaders.Add("Host"); + }); +} var trustedOrigins = configuration.GetSection("ApplicationOptions:TrustedCorsOrigins").Get(); if (trustedOrigins != null)