diff --git a/src/Budget.Api/Program.cs b/src/Budget.Api/Program.cs index 2c0dfc0..8c97441 100644 --- a/src/Budget.Api/Program.cs +++ b/src/Budget.Api/Program.cs @@ -2,6 +2,7 @@ using Budget.Api.Data; using Budget.Api.Services; using Microsoft.AspNetCore.Authentication.JwtBearer; using Microsoft.AspNetCore.Diagnostics.HealthChecks; +using Microsoft.AspNetCore.HttpOverrides; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Diagnostics.HealthChecks; using Microsoft.Extensions.Options; @@ -18,6 +19,13 @@ var connStr = builder.Configuration.GetConnectionString("DefaultConnection") builder.Services.AddDbContext(opt => opt.UseNpgsql(connStr)); +builder.Services.Configure(options => +{ + options.ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto; + options.KnownNetworks.Clear(); + options.KnownProxies.Clear(); +}); + var oidc = builder.Configuration.GetSection("Oidc"); builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) .AddJwtBearer(options => @@ -82,6 +90,8 @@ using (var scope = app.Services.CreateScope()) await db.Database.MigrateAsync(); } +app.UseForwardedHeaders(); + app.UseDefaultFiles(); app.UseStaticFiles();