import { NextRequest , NextResponse } from 'next/server' ; import { first } from '@lib/utils' ; import { botdEdge } from '@lib/botd' ; import demoMiddleware from '@lib/demo-middleware' ; async function handler ( req ) { const res = await botdEdge ( req , { useRequestId : false , } ) ; if ( res && res . status !== 200 ) { const rewrite = NextResponse . rewrite ( '/bot-detected' ) ; res . headers . forEach ( ( v , k ) => rewrite . headers . set ( k , v ) ) ; return rewrite ; } return res ; } export const middleware = first ( demoMiddleware , handler ) ;