Skip to content

Commit

Permalink
reconfigure forwarded headers
Browse files Browse the repository at this point in the history
  • Loading branch information
mythz committed Jan 21, 2024
1 parent 39ba4ef commit c789ea7
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions TechStacks/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,6 @@
.AddDefaultTokenProviders();
builder.Services.AddScoped<IUserClaimsPrincipalFactory<ApplicationUser>, AdditionalUserClaimsPrincipalFactory>();

services.Configure<ForwardedHeadersOptions>(options => {
//https://github.com/aspnet/IISIntegration/issues/140#issuecomment-215135928
options.ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto;
});

services.AddRazorPages();
services.Configure<IdentityOptions>(options =>
{
Expand Down Expand Up @@ -115,13 +110,15 @@
});
});

var app = builder.Build();
// Force Request HTTPS to OAuth redirects include https://
app.Use((ctx, next) => {
ctx.Request.Scheme = "https";
return next();
//https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/proxy-load-balancer?view=aspnetcore-3.1
services.Configure<ForwardedHeadersOptions>(options => {
options.ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto;
});

var app = builder.Build();

app.UseForwardedHeaders();

app.UseMigrationsEndPoint();
app.UseSwagger();
app.UseSwaggerUI();
Expand Down

0 comments on commit c789ea7

Please sign in to comment.