Herstel: admin-bestanden geven 404 in PrerenderedPages-modus

De catch-all 404-route van de website werd ook voor /admin/... gekozen, waardoor de
static-file-middleware (die routes met endpoint overslaat) de adminbestanden niet
serveerde. Een routeconstraint houdt de gereserveerde prefixes buiten die route.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-08 11:12:13 +01:00
co-authored by Claude Sonnet 5.5
parent 05fe0f1f0e
commit d0c1d26c5c
4 changed files with 101 additions and 2 deletions
@@ -65,6 +65,61 @@ public sealed class PrerenderedSiteIntegrationTests : IDisposable
File.WriteAllText(path, content);
}
private void WriteAdmin(string relative, string content)
{
var path = Path.Combine(_root, "wwwroot", "admin", relative);
Directory.CreateDirectory(Path.GetDirectoryName(path)!);
File.WriteAllText(path, content);
}
// Regression guard (live defect on the first ASF test deploy): the admin SPA's files must be served
// in PrerenderedPages mode, not only its index through the SPA fallback.
[Theory]
[InlineData("/admin/index.html", "text/html")]
[InlineData("/admin/assets/index-abc123.css", "text/css")]
[InlineData("/admin/assets/index-abc123.js", "text/javascript")]
[InlineData("/admin/favicon-theme.png", "image/png")]
public async Task AdminFiles_AreServed_InPrerenderedMode(string path, string contentType)
{
WriteAdmin("index.html", "<!doctype html><title>Admin</title>");
WriteAdmin("assets/index-abc123.css", "body{}");
WriteAdmin("assets/index-abc123.js", "console.log(1)");
WriteAdmin("favicon-theme.png", "PNG");
var client = await StartAsync();
var response = await client.GetAsync(path);
response.StatusCode.Should().Be(HttpStatusCode.OK);
response.Content.Headers.ContentType!.MediaType.Should().Be(contentType);
}
[Fact]
public async Task AdminRoot_And_ClientRoutes_ServeTheAdminIndex_InPrerenderedMode()
{
WriteAdmin("index.html", "<!doctype html><title>Admin</title>");
var client = await StartAsync();
foreach (var path in new[] { "/admin/", "/admin/dashboard", "/admin/setup" })
{
var response = await client.GetAsync(path);
response.StatusCode.Should().Be(HttpStatusCode.OK, path);
(await response.Content.ReadAsStringAsync()).Should().Contain("<title>Admin</title>", path);
}
var missing = await client.GetAsync("/admin/assets/missing.js");
missing.StatusCode.Should().Be(HttpStatusCode.NotFound);
(await missing.Content.ReadAsStringAsync()).Should().NotContain("<");
var unknownApi = await client.GetAsync("/api/v1/unknown");
unknownApi.StatusCode.Should().Be(HttpStatusCode.NotFound);
(await unknownApi.Content.ReadAsStringAsync()).Should().BeEmpty();
// The website keeps its own 404 page for a missing asset.
var siteMissing = await client.GetAsync("/assets/missing.js");
siteMissing.StatusCode.Should().Be(HttpStatusCode.NotFound);
(await siteMissing.Content.ReadAsStringAsync()).Should().Contain("Niet gevonden");
}
private async Task<HttpClient> StartAsync(bool noIndex = false, bool prerendered = true, Dictionary<string, string?>? extra = null)
{
Directory.CreateDirectory(Path.Combine(_root, "wwwroot"));