Files
discord.js/apps/guide/src/middleware.ts
Souji 444e55a093 feat(guide): updating section (#11322)
feat: sidebar, layout, initial content

Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>
2025-11-28 11:37:19 +00:00

28 lines
792 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(newUrl);
}
// Redirect old urls to /legacy
if (
!request.nextUrl.pathname.startsWith('/legacy') &&
!request.nextUrl.pathname.startsWith('/voice') &&
!request.nextUrl.pathname.startsWith('/v15')
) {
const newUrl = request.nextUrl.clone();
newUrl.pathname = `/legacy${newUrl.pathname}`;
return NextResponse.redirect(newUrl);
}
return NextResponse.next();
}
export const config = {
matcher: ['/((?!_next|api|og|.*\\..*|_static).*)'],
};