2023-07-05 15:11:16 +02:00
|
|
|
---
|
2023-12-18 14:55:48 +01:00
|
|
|
title: '`NextResponse.next()` used in a Route Handler in the App Router'
|
2023-07-05 15:11:16 +02:00
|
|
|
---
|
2023-02-15 01:16:45 +01:00
|
|
|
|
2023-07-05 15:11:16 +02:00
|
|
|
## Why This Error Occurred
|
2023-02-15 01:16:45 +01:00
|
|
|
|
2023-12-18 14:55:48 +01:00
|
|
|
Route Handlers in the Next.js App Router do not support using the `NextResponse.next()` method to forward to the next Middleware.
|
|
|
|
|
|
|
|
The Route Handler is considered the end of the middleware "chain". Handlers must always return a `Response` object instead.
|
2023-02-15 01:16:45 +01:00
|
|
|
|
2023-07-05 15:11:16 +02:00
|
|
|
## Possible Ways to Fix It
|
2023-02-15 01:16:45 +01:00
|
|
|
|
|
|
|
Remove the `NextResponse.next()` and replace it with a correct response handler.
|
|
|
|
|
2023-07-05 15:11:16 +02:00
|
|
|
## Useful Links
|
2023-02-15 01:16:45 +01:00
|
|
|
|
2023-12-18 14:55:48 +01:00
|
|
|
- [Route Handlers](/docs/app/building-your-application/routing/route-handlers)
|
|
|
|
- [`NextResponse`](/docs/app/api-reference/functions/next-response)
|