U6: SpaFallback-SEO: Website:NoIndex (X-Robots-Tag), robots.txt, sitemap.xml en KnownPaths (echte 404)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -4,6 +4,8 @@ using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.FileProviders;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
using SlpModularCms.Core.Hosting.Website;
|
||||
|
||||
namespace SlpModularCms.Core.Hosting;
|
||||
|
||||
@@ -136,6 +138,15 @@ public static class StaticContentExtensions
|
||||
{
|
||||
if (File.Exists(websiteIndex))
|
||||
{
|
||||
// Website:KnownPaths (optional): only those paths are real pages; the rest is a real 404, still
|
||||
// with the SPA shell as body so the app can render its own not-found page.
|
||||
var known = context.RequestServices.GetService<IOptions<WebsiteOptions>>()?.Value.KnownPaths;
|
||||
if (known is { Count: > 0 }
|
||||
&& !known.Select(SpaSeoExtensions.NormalizePath).Contains(SpaSeoExtensions.NormalizePath(context.Request.Path.Value ?? "/")))
|
||||
{
|
||||
context.Response.StatusCode = StatusCodes.Status404NotFound;
|
||||
}
|
||||
|
||||
context.Response.ContentType = "text/html; charset=utf-8";
|
||||
await context.Response.SendFileAsync(websiteIndex);
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user