Keep static-only routes static when a theme is forced

A ?theme= param or x-gitbook-theme cookie switched every route to the
dynamic tree, but markdown, llms.txt, rss and sitemap routes only exist
under static, so they 404'd. Site previews always persist the theme
cookie, which made View as Markdown 404 there.

Fixes RND-12749
This commit is contained in:
Peter White
2026-10-14 10:46:07 +02:00
parent f7dc7faa65
commit feca902271
+3 -1
View File
@@ -496,7 +496,9 @@ async function serveSiteRoutes(requestURL: URL, request: NextRequest) {
themeMode === CustomizationThemeMode.Dark
? CustomizationDefaultThemeMode.Dark
: CustomizationDefaultThemeMode.Light;
} else {
} else if (routeTypeFromPathname !== 'static') {
// Markdown, llms.txt, RSS and sitemap routes only exist under `sites/static`, so
// forcing them dynamic 404s. They don't render a theme anyway. RND-12749.
routeType = 'dynamic';
requestHeaders.set(MiddlewareHeaders.Theme, themeMode);
}