Browse Source

Use headers

master
Gregory Rudolph 3 years ago
parent
commit
1a7c641253
Signed by: rudi
GPG Key ID: EF64F3CBD1A1EBDD
  1. 7
      Startup.cs

7
Startup.cs

@ -24,6 +24,11 @@ namespace NikolaNet
public void ConfigureServices(IServiceCollection services) public void ConfigureServices(IServiceCollection services)
{ {
services.AddRazorPages(); services.AddRazorPages();
services.Configure<ForwardedHeadersOptions>(options =>
{
options.ForwardedHeaders =
ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto;
});
} }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
@ -32,12 +37,14 @@ namespace NikolaNet
if (env.IsDevelopment()) if (env.IsDevelopment())
{ {
app.UseDeveloperExceptionPage(); app.UseDeveloperExceptionPage();
app.UseForwardedHeaders();
} }
else else
{ {
app.UseExceptionHandler("/Error"); app.UseExceptionHandler("/Error");
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts(); app.UseHsts();
app.UseForwardedHeaders();
} }
app.UseHttpsRedirection(); app.UseHttpsRedirection();

Loading…
Cancel
Save