rsnext/errors/middleware-new-signature.mdx

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

38 lines
751 B
Text
Raw Normal View History

---
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,
})
}
}
```