Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add forwarding headers #1368

Merged
merged 1 commit into from
May 1, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions src/JoinRpg.Portal/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.DataProtection;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.HttpOverrides;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Localization;
using Microsoft.AspNetCore.Mvc;
Expand Down Expand Up @@ -103,6 +104,12 @@ public void ConfigureServices(IServiceCollection services)
.AddAuthentication()
.ConfigureJoinExternalLogins(Configuration.GetSection("Authentication"));

services.Configure<ForwardedHeadersOptions>(options =>
{
options.ForwardedHeaders =
ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto;
});

_ = services.AddSwaggerGen(Swagger.ConfigureSwagger);
_ = services.AddApplicationInsightsTelemetry();

Expand Down Expand Up @@ -157,9 +164,12 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
}
});

_ = app.UseForwardedHeaders();

_ = app
.UseSwagger(Swagger.Configure)
.UseSwaggerUI(Swagger.ConfigureUI);

_ = app.UseSwagger(Swagger.Configure);
_ = app.UseSwaggerUI(Swagger.ConfigureUI);
if (!env.IsDevelopment())
{
_ = app.UseHttpsRedirection();
Expand Down