2 years ago
#62277

Laurence Fass
next js: how to run chain middlware functions from a single file?
The next js docs detail how to create middleware on page calls.
Then, create a _middleware.ts file under your /pages directory.
Finally, export a middleware function from the _middleware.ts file.
// pages/_middleware.ts
import type { NextFetchEvent, NextRequest } from 'next/server'
export function middleware(req: NextRequest, ev: NextFetchEvent) {
return new Response('Hello, world!')
}
how do we chain multiple middleware functions at a specifc level in page hierarchy?
Or is this designed so that each level has one middleware file and function?
next.js
middleware
0 Answers
Your Answer