From 68835b3ff77e2cfe7776da8787f07b0abf02005c Mon Sep 17 00:00:00 2001 From: Naiyar <137700126+imnaiyar@users.noreply.github.com> Date: Mon, 20 Oct 2025 19:13:36 +0600 Subject: [PATCH] refactor(guide): redirect old urls to /legacy (#11170) * refactor(guide): redirect old urls to /legacy * chore: suggestion Co-authored-by: Almeida --------- Co-authored-by: Almeida Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com> --- apps/guide/src/middleware.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/apps/guide/src/middleware.ts b/apps/guide/src/middleware.ts index 5b1ad2aad..442667467 100644 --- a/apps/guide/src/middleware.ts +++ b/apps/guide/src/middleware.ts @@ -5,12 +5,19 @@ export function middleware(request: NextRequest) { if (request.nextUrl.pathname.startsWith('/guide/')) { const newUrl = request.nextUrl.clone(); newUrl.pathname = newUrl.pathname.replace('/guide/', '/'); - return NextResponse.redirect(new URL(newUrl.pathname, request.url)); + return NextResponse.redirect(newUrl); } - return NextResponse.redirect(new URL('/legacy', request.url)); + // Redirect old urls to /legacy + if (!request.nextUrl.pathname.startsWith('/legacy') && !request.nextUrl.pathname.startsWith('/voice')) { + const newUrl = request.nextUrl.clone(); + newUrl.pathname = `/legacy${newUrl.pathname}`; + return NextResponse.redirect(newUrl); + } + + return NextResponse.next(); } export const config = { - matcher: ['/', '/guide/:path*'], + matcher: ['/((?!_next|api|og|.*\\..*|_static).*)'], };