From 4954ead02d673e76bd2ab436ef39f86f07e112c1 Mon Sep 17 00:00:00 2001 From: Khwezi Mngoma Date: Mon, 15 Jun 2026 17:22:20 +0200 Subject: [PATCH] Added https failsafe --- MidrandBookshop/Program.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/MidrandBookshop/Program.cs b/MidrandBookshop/Program.cs index 784f735..e950dc6 100644 --- a/MidrandBookshop/Program.cs +++ b/MidrandBookshop/Program.cs @@ -18,7 +18,7 @@ if (!app.Environment.IsDevelopment()) } app.UseForwardedHeaders(); -//app.UseHttpsRedirection(); +app.UseHttpsRedirection(); app.UseStatusCodePagesWithReExecute("/not-found", createScopeForStatusCodePages: true); app.UseHealthChecks("/health", new HealthCheckOptions @@ -27,6 +27,13 @@ app.UseHealthChecks("/health", new HealthCheckOptions }); app.MapStaticAssets(); +app.Use((context, next) => +{ + if (context.Request.Host.Value!.Contains("midrandbooks.co.za", StringComparison.OrdinalIgnoreCase)) + context.Request.Scheme = "https"; + + return next(); +}); app.UseCookiePolicy(); app.UseAuthentication();