44d1a1cb15
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
37 lines
751 B
Text
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,
|
|
})
|
|
}
|
|
}
|
|
```
|