diff --git a/src/Heimdall.Web/Program.cs b/src/Heimdall.Web/Program.cs index 044e2db..2716aa7 100644 --- a/src/Heimdall.Web/Program.cs +++ b/src/Heimdall.Web/Program.cs @@ -235,12 +235,15 @@ if (!app.Environment.IsDevelopment()) app.UseStatusCodePagesWithReExecute("/not-found", createScopeForStatusCodePages: true); app.UseHttpsRedirection(); -app.UseAntiforgery(); app.UseStaticFiles(); app.UseAuthentication(); app.UseAuthorization(); +// Anti-forgery AFTER auth so unauthenticated API calls get 401 +// before the anti-forgery middleware returns 400. +app.UseAntiforgery(); + app.MapRazorComponents() .AddInteractiveServerRenderMode();