Next.js Discord

Discord Forum

middleware not called

Answered
Wool sower gall maker posted this in #help-forum
Open in Discord
Original message was deleted.
Answered by Wool sower gall maker
import type {NextRequest} from 'next/server'
import {NextFetchEvent, NextResponse} from 'next/server'

// This function can be marked `async` if using `await` inside
export default function middleware(request: NextRequest, ev: NextFetchEvent) {
    console.log("Middleware function called");
    
}

// See "Matching Paths" below to learn more
export const config = {
    matcher: '/dashboard/:path*',
}
snippet from the docs but is not getting called
View full answer

2 Replies

Wool sower gall maker
import type {NextRequest} from 'next/server'
import {NextFetchEvent, NextResponse} from 'next/server'

// This function can be marked `async` if using `await` inside
export default function middleware(request: NextRequest, ev: NextFetchEvent) {
    console.log("Middleware function called");
    
}

// See "Matching Paths" below to learn more
export const config = {
    matcher: '/dashboard/:path*',
}
snippet from the docs but is not getting called
Answer
Wool sower gall maker
needed to include in the src folder..