Remove HSTS

This commit is contained in:
rossmill76 committed 2026-03-07 11:32:36 +00:00
1 parent 613e1fbf47
commit 0b1d31b2b0
2 files changed
+11 -17

No files matched your search

+11 -11
View File
@@ -83,16 +83,16 @@ builder.Services.AddScoped<AppState>();
builder.Services.AddCascadingAuthenticationState();
// HSTS
if (bool.Parse(Environment.GetEnvironmentVariable("ENABLE_HSTS") ?? "false"))
{
builder.Services.AddHsts(options =>
{
var hstsSection = builder.Configuration.GetSection("Hsts");
options.MaxAge = TimeSpan.FromDays(hstsSection.GetValue<int>("MaxAgeDays", 365));
options.IncludeSubDomains = hstsSection.GetValue<bool>("IncludeSubDomains", true);
options.Preload = hstsSection.GetValue<bool>("Preload", false);
});
}
//if (bool.Parse(Environment.GetEnvironmentVariable("ENABLE_HSTS") ?? "false"))
//{
// builder.Services.AddHsts(options =>
// {
// var hstsSection = builder.Configuration.GetSection("Hsts");
// options.MaxAge = TimeSpan.FromDays(hstsSection.GetValue<int>("MaxAgeDays", 365));
// options.IncludeSubDomains = hstsSection.GetValue<bool>("IncludeSubDomains", true);
// options.Preload = hstsSection.GetValue<bool>("Preload", false);
// });
//}
// Add services to the container.
builder.Services.AddRazorComponents()
@@ -112,8 +112,8 @@ if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Error", createScopeForErrors: true);
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
if (bool.Parse(Environment.GetEnvironmentVariable("ENABLE_HSTS") ?? "false")) app.UseHsts();
}
app.UseStatusCodePagesWithReExecute("/not-found");
app.UseHttpsRedirection();