# Component Methods: cms-api-foundation High-level signatures only. Business rules (exact canonicalisation, edge cases, error handling) are defined in Functional Design by the CMS session. Names are indicative; the CMS session may rename them. ## C2. `CmsHostOptions` ```csharp public enum WebsiteMode { SpaFallback = 0, PrerenderedPages = 1 } public sealed class CmsHostOptions { public WebsiteMode WebsiteMode { get; init; } = WebsiteMode.SpaFallback; } ``` ## C3a. `PrerenderedPathResolver` (pure) ```csharp public abstract record SiteResolution; public sealed record ServeFile(string RelativePath, bool IsPage) : SiteResolution; // IsPage drives cache policy public sealed record RedirectTo(string CanonicalPath) : SiteResolution; // 301, query added by caller public sealed record NotFound() : SiteResolution; public sealed class PrerenderedPathResolver { public PrerenderedPathResolver(Func fileExists); public SiteResolution Resolve(PathString requestPath); // total: never throws, never escapes the root } ``` ## C3b. Middleware wiring ```csharp public static IApplicationBuilder UseCmsPrerenderedSite(this WebApplication app, CmsHostOptions options); // - registered where UseCmsStaticContent registers the website mount // - skips reserved prefixes: /admin, /api/v1, /health // - NotFound -> serve 404.html with status 404 (plain 404 if 404.html is missing) ``` ## C3c. `WebsiteCachePolicy` ```csharp public static string CacheControlFor(SiteResolution resolution); // pages: "no-cache"; /assets/*: long-lived immutable; other files: short default ``` ## C3d. `WebsiteIndexingPolicy` ```csharp public sealed class WebsiteOptions { public bool NoIndex { get; set; } } // section "Website" public static IEndpointRouteBuilder MapCmsRobots(this IEndpointRouteBuilder app, WebsiteOptions options); // NoIndex: adds X-Robots-Tag header to website responses and answers /robots.txt "User-agent: *\nDisallow: /" ``` ## C4. `CspPolicyCatalog` ```csharp public const string StrictSite = "StrictSite"; public static SecurityHeaderSet Build(string policy, IEnumerable scriptOrigins, IEnumerable connectOrigins); // StrictSite: script-src 'self' + scriptOrigins; connect-src 'self' + connectOrigins; FrameOptions "DENY". // Strict and Relaxed unchanged. KnownPolicies includes StrictSite. ``` ## C1. `Api.AndreaSlopFotografie/Program.cs` ```csharp var orchestrator = CmsHost.ConfigureServices(builder, new CmsHostOptions { WebsiteMode = WebsiteMode.PrerenderedPages }); var app = builder.Build(); CmsHost.ConfigurePipeline(app, orchestrator, new CmsHostOptions { WebsiteMode = WebsiteMode.PrerenderedPages }); ``` ## C5. Admin theme selection (build time) ```text VITE_THEME -> frontend/themes//theme.css (+ logo, favicon); unset = default theme VITE_DEFAULT_LANGUAGE -> "nl" | "en"; unset = current default VITE_APP_TITLE -> existing ``` ## C8. Deployment verification (shell, extends the existing script) ```text verify_csp_equals # expectedCsp generated from contentSecurityPolicy('production') verify_status verify_redirect verify_header ```