Skip to content

Commit

Permalink
Don't register HTTP logging services if option is disabled in appsett…
Browse files Browse the repository at this point in the history
…ings.
  • Loading branch information
bitbound committed May 16, 2023
1 parent 0857b38 commit c1fffe2
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions Server/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,17 +111,20 @@
services.AddServerSideBlazor();
services.AddScoped<AuthenticationStateProvider, RevalidatingIdentityAuthenticationStateProvider<RemotelyUser>>();
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<string[]>();

if (trustedOrigins != null)
Expand Down

0 comments on commit c1fffe2

Please sign in to comment.