mirror of
https://github.com/vercel/next.js.git
synced 2026-09-20 02:25:18 +08:00
11 lines
312 B
TypeScript
11 lines
312 B
TypeScript
import { notFound, redirect } from 'next/navigation'
|
|
import { NextRequest } from 'next/server'
|
|
|
|
export default function middleware(req: NextRequest) {
|
|
if (req.nextUrl.pathname === '/middleware/not-found') {
|
|
notFound()
|
|
} else if (req.nextUrl.pathname === '/middleware/redirect') {
|
|
redirect('/')
|
|
}
|
|
}
|