fix(public): move UseStatusCodePagesWithReExecute before UseAntiforgery to fix 404 re-execution antiforgery error

This commit is contained in:
daniel-c-harvey
2026-06-16 18:43:56 -04:00
parent b5fdb826b0
commit d8d908d4a6
+4 -3
View File
@@ -100,6 +100,10 @@ app.Use(async (context, next) =>
await next(); await next();
}); });
// StatusCodePages must sit upstream of UseAntiforgery so that re-executed requests
// (e.g. /404) flow through the antiforgery middleware before reaching the endpoint.
app.UseStatusCodePagesWithReExecute("/404", createScopeForStatusCodePages: true);
// Antiforgery is required by Blazor form handling. Authentication / authorization // Antiforgery is required by Blazor form handling. Authentication / authorization
// middleware is intentionally absent — this host is fully anonymous. // middleware is intentionally absent — this host is fully anonymous.
app.UseAntiforgery(); app.UseAntiforgery();
@@ -144,7 +148,4 @@ app.MapRazorComponents<App>()
.AddInteractiveWebAssemblyRenderMode() .AddInteractiveWebAssemblyRenderMode()
.AddAdditionalAssemblies(typeof(DeepDrftPublic.Client._Imports).Assembly); .AddAdditionalAssemblies(typeof(DeepDrftPublic.Client._Imports).Assembly);
app.UseStatusCodePagesWithReExecute("/404", createScopeForStatusCodePages: true);
app.Run(); app.Run();