From 8ea0c769d8d2a79bacddc0703efb93933df4b1b4 Mon Sep 17 00:00:00 2001 From: James Chapman Date: Sat, 11 Nov 2023 22:41:28 +0000 Subject: [PATCH] Fix X-Forwarded-* headers ignored when running in container --- Groceries/Program.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Groceries/Program.cs b/Groceries/Program.cs index a799385..10d5c60 100644 --- a/Groceries/Program.cs +++ b/Groceries/Program.cs @@ -34,6 +34,13 @@ if (!dbUpgradeResult.Successful) return -1; } +builder.Services.Configure(options => +{ + options.ForwardedHeaders = ForwardedHeaders.All; + options.KnownNetworks.Clear(); + options.KnownProxies.Clear(); +}); + var dataProtection = builder.Services.AddDataProtection(); if (env.IsProduction()) { @@ -86,7 +93,7 @@ builder.Services.AddDbContextPool(options => options var app = builder.Build(); -app.UseForwardedHeaders(new() { ForwardedHeaders = ForwardedHeaders.All }); +app.UseForwardedHeaders(); app.UseStaticFiles(); app.UseRouting();