From 923529a132f4aaf3b60d29be2a546b6a0a3c5f88 Mon Sep 17 00:00:00 2001 From: bntvllnt Date: Thu, 18 Jun 2026 21:47:16 +0200 Subject: [PATCH] fix(registry): redirect /design.md to canonical /DESIGN.md Lowercase /design.md returned 404 while /DESIGN.md (referenced in sitemap.ts, llms.txt and llms-full.txt) served the design guide. Add a 308 redirect so the natural lowercase guess resolves to the canonical markdown route. Done in middleware, not a route folder or next.config: a sibling app/design.md/route.ts is rejected by tsc (folder casing collision with DESIGN.md), and next.config redirects() match case-insensitively, which would loop /DESIGN.md -> /DESIGN.md. A case-sensitive check in middleware avoids both while leaving the canonical route untouched. Closes #447 Claude-Session: https://claude.ai/code/session_01Kx4Zwv76SZhVxwctKsquBN --- apps/registry/middleware.ts | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/apps/registry/middleware.ts b/apps/registry/middleware.ts index 75185a78..5fd427cc 100644 --- a/apps/registry/middleware.ts +++ b/apps/registry/middleware.ts @@ -1,11 +1,33 @@ +import { type NextRequest, NextResponse } from "next/server"; import createMiddleware from "next-intl/middleware"; import { routing } from "@/i18n/routing"; -export default createMiddleware(routing); +const intlMiddleware = createMiddleware(routing); + +export default function middleware(request: NextRequest): NextResponse { + const { pathname } = request.nextUrl; + + // Case-sensitive redirect for the lowercase guess of the design guide. + // Can't use a route folder (tsc rejects design.md colliding with DESIGN.md) + // nor next.config redirects() (matches case-insensitively -> loops /DESIGN.md). + if (pathname === "/design.md") { + const target = request.nextUrl.clone(); + target.pathname = "/DESIGN.md"; + + return NextResponse.redirect(target, 308); + } + + if (pathname.toLowerCase() === "/design.md") { + return NextResponse.next(); + } + + return intlMiddleware(request); +} export const config = { matcher: [ + "/design.md", "/((?!api|_next|_vercel|mcp|embed|r/|atom\\.xml|rss\\.xml|design\\.txt|llms\\.txt|llms-full\\.txt|sitemap\\.xml|robots\\.txt|manifest\\.webmanifest|.*\\.[^/]+$).*)", ], };