[PR #320] [MERGED] feat: support export const revalidate on App Router GET route handlers #478

Closed
opened 2026-05-06 13:08:17 +02:00 by BreizhHardware · 0 comments

📋 Pull Request Information

Original PR: https://github.com/cloudflare/vinext/pull/320
Author: @NathanDrake2406
Created: 3/7/2026
Status: Merged
Merged: 3/7/2026
Merged by: @james-elicx

Base: mainHead: feat/route-handler-revalidate


📝 Commits (3)

  • 302fe2b chore: add .worktrees/ to gitignore
  • 538d598 feat: support export const revalidate on App Router GET route handlers
  • b602397 fix: guard revalidate=0 and add proper test fixtures

📊 Changes

6 files changed (+67 additions, -5 deletions)

View changed files

📝 .gitignore (+3 -0)
📝 packages/vinext/src/server/app-dev-server.ts (+7 -0)
📝 tests/e2e/app-router/api-routes.spec.ts (+4 -5)
tests/fixtures/app-basic/app/api/custom-cache/route.ts (+12 -0)
tests/fixtures/app-basic/app/api/no-cache/route.ts (+9 -0)
📝 tests/nextjs-compat/app-routes.test.ts (+32 -0)

📄 Description

Summary

  • Read export const revalidate = N from route handler modules in the App Router dev server
  • Set Cache-Control: s-maxage=N, stale-while-revalidate on GET responses when the handler doesn't set its own Cache-Control
  • Unskip two E2E test.fixme cases for route handler cache headers (ported from OpenNext)
  • Add two vitest cases in app-routes.test.ts for header emission and no-override behavior

Closes the behavioral gap where vinext ignored route segment config on route handlers, only reading it from page modules.

Test plan

  • pnpm test tests/nextjs-compat/app-routes.test.ts — 25 tests pass (2 new)
  • pnpm run typecheck — clean
  • pnpm run lint — clean
  • E2E: api-routes.spec.ts "Route Handler Cache Headers" describe block (2 unskipped tests)
  • CI: full Vitest + Playwright suite

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/cloudflare/vinext/pull/320 **Author:** [@NathanDrake2406](https://github.com/NathanDrake2406) **Created:** 3/7/2026 **Status:** ✅ Merged **Merged:** 3/7/2026 **Merged by:** [@james-elicx](https://github.com/james-elicx) **Base:** `main` ← **Head:** `feat/route-handler-revalidate` --- ### 📝 Commits (3) - [`302fe2b`](https://github.com/cloudflare/vinext/commit/302fe2b92c8e76840bccb03c7aae88162f434cb9) chore: add .worktrees/ to gitignore - [`538d598`](https://github.com/cloudflare/vinext/commit/538d598469e0d3b3c659abc9e0ac1ab1920d7523) feat: support `export const revalidate` on App Router GET route handlers - [`b602397`](https://github.com/cloudflare/vinext/commit/b6023971a3a0145e6743fba0d5edbcbe1ed8ae34) fix: guard revalidate=0 and add proper test fixtures ### 📊 Changes **6 files changed** (+67 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `.gitignore` (+3 -0) 📝 `packages/vinext/src/server/app-dev-server.ts` (+7 -0) 📝 `tests/e2e/app-router/api-routes.spec.ts` (+4 -5) ➕ `tests/fixtures/app-basic/app/api/custom-cache/route.ts` (+12 -0) ➕ `tests/fixtures/app-basic/app/api/no-cache/route.ts` (+9 -0) 📝 `tests/nextjs-compat/app-routes.test.ts` (+32 -0) </details> ### 📄 Description ## Summary - Read `export const revalidate = N` from route handler modules in the App Router dev server - Set `Cache-Control: s-maxage=N, stale-while-revalidate` on GET responses when the handler doesn't set its own Cache-Control - Unskip two E2E `test.fixme` cases for route handler cache headers (ported from OpenNext) - Add two vitest cases in `app-routes.test.ts` for header emission and no-override behavior Closes the behavioral gap where vinext ignored route segment config on route handlers, only reading it from page modules. ## Test plan - [x] `pnpm test tests/nextjs-compat/app-routes.test.ts` — 25 tests pass (2 new) - [x] `pnpm run typecheck` — clean - [x] `pnpm run lint` — clean - [x] E2E: `api-routes.spec.ts` "Route Handler Cache Headers" describe block (2 unskipped tests) - [x] CI: full Vitest + Playwright suite --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
BreizhHardware 2026-05-06 13:08:17 +02:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/vinext#478
No description provided.