From abee3090f4f490ff392779b17487609b197f790e Mon Sep 17 00:00:00 2001 From: Emir Karabeg Date: Wed, 19 Feb 2025 19:02:30 -0800 Subject: [PATCH] improvement(middleware): added /w to route to /w/1 --- middleware.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/middleware.ts b/middleware.ts index 211337f155..dd2544fbc8 100644 --- a/middleware.ts +++ b/middleware.ts @@ -2,6 +2,12 @@ import { NextRequest, NextResponse } from 'next/server' import { getSessionCookie } from 'better-auth' export async function middleware(request: NextRequest) { + // Check if the path is exactly /w + if (request.nextUrl.pathname === '/w') { + return NextResponse.redirect(new URL('/w/1', request.url)) + } + + // Existing auth check for protected routes const sessionCookie = getSessionCookie(request) if (!sessionCookie) { return NextResponse.redirect(new URL('/login', request.url)) @@ -11,5 +17,8 @@ export async function middleware(request: NextRequest) { // TODO: Add protected routes export const config = { - matcher: ['/w/:path*'], + matcher: [ + '/w', // Match exactly /w + '/w/:path*', // Keep existing matcher for protected routes + ], }