Found while standing up the API test tier (#37, PR #38).
Program.cs runs one middleware pipeline for both the Blazor UI and the minimal API under /api,
and the two want different behaviour. Concretely: UseStatusCodePagesWithReExecute("/not-found")
re-executes with the original request method, so an unauthorized POST /api/matches was re-run
against a Razor component and answered 400 "The request has an incorrect Content-type." instead
of 401. An API client would have seen a wrong status with no way to tell why.
PR #38 patches the symptom by scoping the re-execution to non-/api paths. The shape of the problem
is more general — the same pipeline also applies HTML-oriented exception handling, HSTS and
antiforgery to JSON requests — so it is worth separating properly rather than adding another
UseWhen each time this bites.
Found while standing up the API test tier (#37, PR #38).
Program.csruns one middleware pipeline for both the Blazor UI and the minimal API under/api,and the two want different behaviour. Concretely:
UseStatusCodePagesWithReExecute("/not-found")re-executes with the original request method, so an unauthorized
POST /api/matcheswas re-runagainst a Razor component and answered 400 "The request has an incorrect Content-type." instead
of 401. An API client would have seen a wrong status with no way to tell why.
PR #38 patches the symptom by scoping the re-execution to non-
/apipaths. The shape of the problemis more general — the same pipeline also applies HTML-oriented exception handling, HSTS and
antiforgery to JSON requests — so it is worth separating properly rather than adding another
UseWheneach time this bites./apigets JSON problem-details error handling and no status-codere-execution; everything else keeps the UI behaviour
ProblemDetailsfrom the API on 4xx/5xx (AddProblemDetails)Ssabba.Web.Tests: unauthorized write is 401, unknown/apiroute is 404, andneither is rewritten into an HTML response