Skip to content

Commit

Permalink
Use forwarded headers
Browse files Browse the repository at this point in the history
  • Loading branch information
donaldgray committed May 22, 2024
1 parent a2f8ede commit ef1e7d1
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions LeedsExperiment/Preservation.API/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Text.Json;
using System.Text.Json.Serialization;
using Amazon.S3;
using Microsoft.AspNetCore.HttpOverrides;
using Microsoft.OpenApi.Models;
using Preservation;
using Preservation.API;
Expand Down Expand Up @@ -64,11 +65,17 @@
opts.IncludeXmlComments(Path.Combine(AppContext.BaseDirectory, xmlFilename));
});

builder.Services.Configure<ForwardedHeadersOptions>(opts =>
{
opts.ForwardedHeaders = ForwardedHeaders.XForwardedHost | ForwardedHeaders.XForwardedProto;
});

var app = builder.Build();

app.MapGet("/ping", () => "pong");

app.TryRunMigrations(app.Configuration, app.Logger);
app.UseForwardedHeaders();
app.UseSwagger();
app.UseSwaggerUI();
app.UseHttpsRedirection();
Expand Down

0 comments on commit ef1e7d1

Please sign in to comment.