mirror of
https://github.com/vercel/next.js.git
synced 2026-09-20 02:25:18 +08:00
71ce95dffa
> [!NOTE] > Best reviewed by each commit for better diff view. This PR clones the Middleware docs for Proxy and removes the Middleware docs. Did not clone the list of docs: - `errors/middleware-upgrade.mdx` - It's a middleware upgrade guide from v12.2 - `errors/beta-middleware.mdx` - It's an error when using middleware before v12.2 - `errors/returning-response-body.mdx` - Legacy behavior from versions < v12.2
38 lines
716 B
Plaintext
38 lines
716 B
Plaintext
---
|
|
title: Deprecated Proxy API Signature
|
|
---
|
|
|
|
## Why This Error Occurred
|
|
|
|
Your application is using a Proxy function that is using parameters from the deprecated API.
|
|
|
|
```ts filename="proxy.ts"
|
|
import { NextResponse } from 'next/server'
|
|
|
|
export function proxy(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 Proxy:
|
|
|
|
```ts filename="proxy.ts"
|
|
import { NextResponse } from 'next/server'
|
|
|
|
export function proxy(request) {
|
|
if (request.nextUrl.pathname === '/blocked') {
|
|
return new NextResponse(null, {
|
|
status: 403,
|
|
})
|
|
}
|
|
}
|
|
```
|