3 Commits

Author SHA1 Message Date
Nathan Nguyen cf5471e95a fix(app-router): fixing cache request leaks (#907) 2026-04-29 14:59:14 +01:00
Nathan Nguyen e9139542cb fix(app-router): reject middleware control responses in route handlers (#939)
* fix(app-router): reject middleware control responses in route handlers

App Route handlers currently treat NextResponse.next() and NextResponse.rewrite() as ordinary 200 responses. That diverges from Next.js, where those helpers are middleware control-flow signals and are rejected after a route handler returns.

The route-handler execution path now validates returned responses before cache policy or response finalization runs. Focused unit and integration tests cover the invalid next and rewrite helper responses.

* Update tests/app-route-handler-execution.test.ts

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update packages/vinext/src/server/app-route-handler-response.ts

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* fix(app-router): validate route handler ISR regeneration responses

Stale App Route handler regeneration called runAppRouteHandler directly and could serialize a middleware control response into the ISR cache. That bypassed the validation used by the live route-handler execution path.

Run the same response assertion before background regeneration writes a new APP_ROUTE cache entry, restore exact Next.js error wording for parity, and cover the x-middleware-next boundary semantics.

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-04-28 20:36:17 +01:00
Steve Faulkner 4af18c72f5 refactor: extract app route handler execution helpers (#624) 2026-03-21 09:33:26 -05:00