diff --git a/aidlc-docs/features/andreaslop-site-hosting/audit.md b/aidlc-docs/features/andreaslop-site-hosting/audit.md
index 7e4574b..7118a39 100644
--- a/aidlc-docs/features/andreaslop-site-hosting/audit.md
+++ b/aidlc-docs/features/andreaslop-site-hosting/audit.md
@@ -454,3 +454,9 @@
**Run**: 608, workflow_dispatch on feature/andreaslop-site-hosting (deploy_asf_test=true only; test/production false). All gates green, publish-asf-test and deploy-asf-test succeeded (health check through https://test.andreaslop.nl/health passed), SlpSoftware jobs skipped.
**Verification by curl (https://test.andreaslop.nl)**: / 200 with full header set (CSP byte-exact, HSTS, nosniff, DENY, Referrer-Policy, X-Robots-Tag noindex), Cache-Control no-cache; /assets immutable; gzip on GET, no br; /Over-Mij -> 301 /over-mij; /a%3Fb/ -> 301 /a%3Fb; /doesnotexist and /404.html -> 404 with the 404 page and headers; /api/v1/onbekend-pad -> 404 empty; /robots.txt Disallow: /; POST on a page -> 405 Allow: GET, HEAD; /health 200 (version 1.0.0+91f14d5); /admin/ 200 with theme favicon; capabilities = Identity, Availability; Setup status = initialized false, tokenRequired true.
**Observations**: bare `curl -X POST /` (no body/Content-Length) answers 400 via the HTTP/1.0 proxy hop, `-d ''` gives 405; forwarded-header effect not yet observed; Sentry rules and first administrator still open.
+
+## Defect on the first ASF test deploy: admin files 404 (U1 code)
+**Timestamp**: 2026-11-08
+**Found by**: Bryan (blank /admin), analysed with CMS & API.
+**Root cause**: `MapCmsWebsiteNotFound` maps the catch-all `{*path}` without `nonfile`; routing selects it as endpoint for /admin/assets/x.css and the static-file middleware skips requests that already have an endpoint, so only the admin index (SPA fallback) worked. Existing tests only fetched /admin/. Reproduced locally by 4 failing tests first.
+**Fix**: route constraint `notreserved` (`NotReservedPathConstraint`) on the catch-all so the reserved prefixes (/admin, /api/v1, /health) behave exactly as in SpaFallback mode (chosen over clearing/restoring the endpoint: simpler, covers future prefixes). Tests: admin index/css/js/favicon 200 with content types, /admin/dashboard SPA index, unknown admin asset 404 non-HTML, unknown /api/v1 empty 404, website /assets/missing.js still the 404 page. Open (pre-existing, not changed): admin inline theme-init script is blocked by CSP script-src 'self' (same on SlpSoftware); candidates: externalise the script or hash it in the admin policy.
diff --git a/src/SlpModularCms.Core.Tests/Hosting/Website/PrerenderedSiteIntegrationTests.cs b/src/SlpModularCms.Core.Tests/Hosting/Website/PrerenderedSiteIntegrationTests.cs
index d48026d..702aefc 100644
--- a/src/SlpModularCms.Core.Tests/Hosting/Website/PrerenderedSiteIntegrationTests.cs
+++ b/src/SlpModularCms.Core.Tests/Hosting/Website/PrerenderedSiteIntegrationTests.cs
@@ -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", "
Admin");
+ 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", "Admin");
+ 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("Admin", 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 StartAsync(bool noIndex = false, bool prerendered = true, Dictionary? extra = null)
{
Directory.CreateDirectory(Path.Combine(_root, "wwwroot"));
diff --git a/src/SlpModularCms.Core/Hosting/Website/NotReservedPathConstraint.cs b/src/SlpModularCms.Core/Hosting/Website/NotReservedPathConstraint.cs
new file mode 100644
index 0000000..29631fc
--- /dev/null
+++ b/src/SlpModularCms.Core/Hosting/Website/NotReservedPathConstraint.cs
@@ -0,0 +1,33 @@
+using Microsoft.AspNetCore.Http;
+using Microsoft.AspNetCore.Routing;
+
+namespace SlpModularCms.Core.Hosting.Website;
+
+///
+/// Route constraint for the website's catch-all 404 route: it refuses the reserved prefixes
+/// (/admin, /api/v1, /health).
+///
+///
+/// Without it the catch-all (which deliberately has no 'nonfile' constraint, so a missing
+/// /assets/x.js gets the 404 page) is selected for every request, including
+/// /admin/assets/x.css. The static-file middleware skips requests that already have an
+/// endpoint, so the admin's files would 404. With the constraint the reserved prefixes behave exactly
+/// as in : the admin keeps its own 'nonfile' fallback, an unknown
+/// file under /admin is a plain 404 from the static layer, an unknown /api/v1/x stays
+/// an empty 404.
+///
+public sealed class NotReservedPathConstraint : IRouteConstraint
+{
+ public const string Name = "notreserved";
+
+ public bool Match(HttpContext? httpContext, IRouter? route, string routeKey, RouteValueDictionary values,
+ RouteDirection routeDirection)
+ {
+ if (!values.TryGetValue(routeKey, out var value) || value is null)
+ {
+ return true;
+ }
+
+ return !WebsitePathResolver.IsReservedPath("/" + value);
+ }
+}
diff --git a/src/SlpModularCms.Core/Hosting/Website/PrerenderedSiteExtensions.cs b/src/SlpModularCms.Core/Hosting/Website/PrerenderedSiteExtensions.cs
index 092fb71..ea3f566 100644
--- a/src/SlpModularCms.Core/Hosting/Website/PrerenderedSiteExtensions.cs
+++ b/src/SlpModularCms.Core/Hosting/Website/PrerenderedSiteExtensions.cs
@@ -37,6 +37,10 @@ public static class PrerenderedSiteExtensions
provider.GetRequiredService().CreateLogger(PrerenderedSiteMiddleware.LoggerCategory));
});
+ // Lets the catch-all 404 route refuse the reserved prefixes (see NotReservedPathConstraint).
+ services.Configure(options =>
+ options.ConstraintMap[NotReservedPathConstraint.Name] = typeof(NotReservedPathConstraint));
+
// gzip only, like nginx today; Brotli is deliberately not registered.
services.AddResponseCompression(options =>
{
@@ -66,8 +70,9 @@ public static class PrerenderedSiteExtensions
public static WebApplication MapCmsWebsiteNotFound(this WebApplication app)
{
// An explicit pattern: the default fallback pattern carries the "nonfile" constraint, and a
- // missing asset (/assets/x.js) must also get the 404 page, not a bare framework 404.
- app.MapFallback("{*path}", WebsiteNotFoundHandler.HandleAsync);
+ // missing asset (/assets/x.js) must also get the 404 page, not a bare framework 404. The
+ // reserved prefixes are excluded so they keep their own behaviour (see NotReservedPathConstraint).
+ app.MapFallback($"{{*path:{NotReservedPathConstraint.Name}}}", WebsiteNotFoundHandler.HandleAsync);
return app;
}
}