Skip to content

Commit 20db8fe

Browse files
another test
1 parent eb5f577 commit 20db8fe

1 file changed

Lines changed: 23 additions & 14 deletions

File tree

EssentialCSharp.Web/Program.cs

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,14 @@ public partial class Program
1717
{
1818
private static void Main(string[] args)
1919
{
20-
WebApplicationBuilder builder = WebApplication.CreateBuilder(args);
20+
WebApplicationBuilder builder = WebApplication.CreateBuilder(args);
21+
22+
builder.Services.Configure<ForwardedHeadersOptions>(options =>
23+
{
24+
options.ForwardedHeaders =
25+
ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto;
26+
});
27+
2128
ConfigurationManager configuration = builder.Configuration;
2229
string connectionString = builder.Configuration.GetConnectionString("EssentialCSharpWebContextConnection") ?? throw new InvalidOperationException("Connection string 'EssentialCSharpWebContextConnection' not found.");
2330

@@ -138,29 +145,31 @@ private static void Main(string[] args)
138145
});
139146
}
140147

141-
builder.Services.Configure<ForwardedHeadersOptions>(options =>
142-
{
143-
options.ForwardedHeaders =
144-
ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto;
145-
});
146-
147-
WebApplication app = builder.Build();
148-
app.UseForwardedHeaders();
149-
app.Use((context, next) =>
150-
{
151-
context.Request.Scheme = "https";
152-
return next(context);
153-
});
154148

155149

150+
WebApplication app = builder.Build();
156151
// Configure the HTTP request pipeline.
157152
if (!app.Environment.IsDevelopment())
158153
{
159154
app.UseExceptionHandler("/Error");
155+
app.UseForwardedHeaders();
160156
app.UseHsts();
161157
app.UseSecurityHeadersMiddleware(new SecurityHeadersBuilder()
162158
.AddDefaultSecurePolicy());
163159
}
160+
else
161+
{
162+
app.UseDeveloperExceptionPage();
163+
app.UseForwardedHeaders();
164+
}
165+
166+
//app.Use((context, next) =>
167+
//{
168+
// context.Request.Scheme = "https";
169+
// return next(context);
170+
//});
171+
172+
164173

165174
app.MapHealthChecks("/healthz");
166175

0 commit comments

Comments
 (0)