Middleware is not working
Unanswered
Atlantic mackerel posted this in #help-forum
Atlantic mackerelOP
Hey guys im trying to add middleware for my app but it isn't working at all
Im trying this:
and my project struct look like
how can I add middleware?
Im trying this:
// middleware.ts
import { NextResponse } from 'next/server'
import type { NextRequest } from 'next/server'
export function middleware(request: NextRequest) {
console.log("test")
}
export const config = {
matcher: '/',
}and my project struct look like
photo how can I add middleware?
3 Replies
Cape lion
hmm i use the pages router, and put my /pages dir inside a /src/ directory and the middleware.ts runs inside the source directory...
are you expecting it to run only at /?
@Cape lion are you expecting it to run only at /?
Atlantic mackerelOP
Im new to nextjs sooo I dunno howto setup middleware when I put middleware.ts file to app folder it doesn't work