From ed686718d3d3f531bf23bbff15f98ebf1b811a80 Mon Sep 17 00:00:00 2001 From: Arnaud Dartois Date: Tue, 21 Jul 2026 07:38:38 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20remove=20UseStatusCodePagesWithReExecute?= =?UTF-8?q?=20=E2=80=94=20was=20turning=20401=20into=20400?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit UseStatusCodePagesWithReExecute('/not-found') intercepts all 4xx responses and re-executes the pipeline as POST /not-found. Since /not-found is a Blazor component requiring antiforgery, the re-executed POST would fail with 400 (no CSRF token). API controllers now return proper 401/403 for unauthenticated requests. All 61 integration tests pass. --- src/Heimdall.Web/Controllers/DiscoveryController.cs | 1 + src/Heimdall.Web/Program.cs | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Heimdall.Web/Controllers/DiscoveryController.cs b/src/Heimdall.Web/Controllers/DiscoveryController.cs index f19a33b..8c92e4c 100644 --- a/src/Heimdall.Web/Controllers/DiscoveryController.cs +++ b/src/Heimdall.Web/Controllers/DiscoveryController.cs @@ -14,6 +14,7 @@ namespace Heimdall.Api.Controllers; /// [ApiController] [Route("api/discovery")] +[Authorize(AuthenticationSchemes = "JwtBearer")] [EnableRateLimiting("Api")] public class DiscoveryController : ControllerBase { diff --git a/src/Heimdall.Web/Program.cs b/src/Heimdall.Web/Program.cs index 2716aa7..99bf3fc 100644 --- a/src/Heimdall.Web/Program.cs +++ b/src/Heimdall.Web/Program.cs @@ -233,7 +233,6 @@ if (!app.Environment.IsDevelopment()) app.UseHsts(); } -app.UseStatusCodePagesWithReExecute("/not-found", createScopeForStatusCodePages: true); app.UseHttpsRedirection(); app.UseStaticFiles();