rsnext/errors/next-response-next-in-app-route-handler.mdx
Lee Robinson 1c65c55750
docs: improve docs around geolocation and IP headers (#59719)
Based on feedback from https://github.com/vercel/next.js/issues/47793, I
made some improvements around the geolocation docs. Specifically around
`request.ip`, `request.geo`, and how to access these values. I noticed
there was a bit of a divergence, as some of the `NextRequest` and
`NextResponse` docs were split out for the App Router section, but not
all.

This PR finishes that swing by removing the previous catch-all for
`next/server` in the Pages Router docs and splits them into individual
docs pages.

Wrote a lil' thread about this:
https://twitter.com/leeerob/status/1736543599339172121

---------

Co-authored-by: Delba de Oliveira <32464864+delbaoliveira@users.noreply.github.com>
2023-12-18 07:55:48 -06:00

18 lines
640 B
Text

---
title: '`NextResponse.next()` used in a Route Handler in the App Router'
---
## Why This Error Occurred
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.
## Possible Ways to Fix It
Remove the `NextResponse.next()` and replace it with a correct response handler.
## Useful Links
- [Route Handlers](/docs/app/building-your-application/routing/route-handlers)
- [`NextResponse`](/docs/app/api-reference/functions/next-response)