Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion apps/registry/middleware.ts
Original file line number Diff line number Diff line change
@@ -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|.*\\.[^/]+$).*)",
],
};
Loading