middleware.ts
// middleware.ts
import { NextResponse } from 'next/server'
import type { NextRequest } from 'next/server'

// This function can be marked `async` if using `await` inside
export function middleware(request: NextRequest) {
  return NextResponse.redirect(new URL('/about-2', request.url))
}

// See "Matching Paths" below to learn more
export const config = {
  matcher: '/about/:path*',
}

All you need is to create a function

called middleware inside middleware.ts

and it will be executed per request.

this will redirect to /about-2 whenever

there is an api request that matches

the path inside config i.e. /about/:path