Files
discord.js/apps/guide/src/middleware.ts
Almeida 7de5b4a349 refactor: remove guide route prefix (#11146)
* refactor: remove guide route prefix

* chore: implement backwards compat redirect

* Change guide redirect destination and permanence

Updated the redirect destination and permanence for the guide route.

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2025-10-07 09:50:53 +00:00

17 lines
508 B
TypeScript

import { NextResponse, type NextRequest } from 'next/server';
export function middleware(request: NextRequest) {
// TODO: Remove this eventually
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(new URL('/legacy', request.url));
}
export const config = {
matcher: ['/', '/guide/:path*'],
};