rsnext/errors/middleware-new-signature.mdx
Delba de Oliveira 44d1a1cb15
docs: Migrate error messages to MDX and App Router. (#52038)
This PR is part of a larger effort to migrate error messages to MDX and
use App Router: https://github.com/vercel/front/pull/23459
2023-07-05 06:11:16 -07:00

37 lines
751 B
Text

---
title: Deprecated Middleware API Signature
---
## Why This Error Occurred
Your application is using a Middleware function that is using parameters from the deprecated API.
```ts filename="middleware.ts"
import { NextResponse } from 'next/server'
export function middleware(event) {
if (event.request.nextUrl.pathname === '/blocked') {
event.respondWith(
new NextResponse(null, {
status: 403,
})
)
}
}
```
## Possible Ways to Fix It
Update to use the new API for Middleware:
```ts filename="middleware.ts"
import { NextResponse } from 'next/server'
export function middleware(request) {
if (request.nextUrl.pathname === '/blocked') {
return new NextResponse(null, {
status: 403,
})
}
}
```