This issue was created by an agent analysing CI failures from the Next.js Deploy Suite (vinext main vs Next.js v16.2.6, 2026-05-20).
Problem
The Pages Router production server does not handle /_next/data/[buildId]/[page].json requests. In Next.js, client-side navigations in the Pages Router fetch page data from this endpoint, which returns a JSON object like {"pageProps":{"message":"Hello"}}.
When vinext receives these requests, it either:
- Returns 404 — does not recognize the
_next/data URL pattern
- Returns HTML — serves the full rendered page instead of the JSON data envelope
Additionally, middleware URL normalization is missing: middleware sees the raw /_next/data/.../page.json path instead of the normalized page path (e.g., /page).
FetchError: invalid json response body at
http://127.0.0.1:33447/_next/data/e6777d6d-.../es/about.json
reason: Unexpected token '<', "<!DOCTYPE "... is not valid JSON
Expected: "/send-url/"
Received: "/_next/data/49d16a23-.../send-url.json"
Estimated Impact
~30 test failures across the deploy suite.
Affected Test Suites
test/e2e/middleware-trailing-slash/test/index.test.ts
test/e2e/middleware-general/test/index.test.ts
test/e2e/middleware-general/test/node-runtime.test.ts
test/e2e/middleware-rewrites/test/index.test.ts
test/e2e/middleware-redirects/test/index.test.ts
test/e2e/middleware-redirects/test/node-runtime.test.ts
test/e2e/edge-pages-support/index.test.ts
test/e2e/prerender.test.ts
Recommendation
-
Reproduce first in vinext's own test suite. Add a test case that makes a request to /_next/data/[buildId]/[page].json on a Pages Router app and asserts it returns JSON with the correct pageProps. Confirm it fails before implementing the fix.
-
Implement a _next/data route handler in server/prod-server.ts. Intercept requests matching /_next/data/[buildId]/[page].json, extract the page path, call the page's getServerSideProps/getStaticProps, and return the result as { pageProps: ... } JSON.
-
Implement URL normalization in the middleware pipeline. Before passing requests to middleware, strip the /_next/data/[buildId]/ prefix and .json suffix so middleware sees the canonical page path (e.g., /send-url/ instead of /_next/data/.../send-url.json).
-
Check dev/prod parity. Ensure server/dev-server.ts also handles data requests consistently.
Problem
The Pages Router production server does not handle
/_next/data/[buildId]/[page].jsonrequests. In Next.js, client-side navigations in the Pages Router fetch page data from this endpoint, which returns a JSON object like{"pageProps":{"message":"Hello"}}.When vinext receives these requests, it either:
_next/dataURL patternAdditionally, middleware URL normalization is missing: middleware sees the raw
/_next/data/.../page.jsonpath instead of the normalized page path (e.g.,/page).Estimated Impact
~30 test failures across the deploy suite.
Affected Test Suites
test/e2e/middleware-trailing-slash/test/index.test.tstest/e2e/middleware-general/test/index.test.tstest/e2e/middleware-general/test/node-runtime.test.tstest/e2e/middleware-rewrites/test/index.test.tstest/e2e/middleware-redirects/test/index.test.tstest/e2e/middleware-redirects/test/node-runtime.test.tstest/e2e/edge-pages-support/index.test.tstest/e2e/prerender.test.tsRecommendation
Reproduce first in vinext's own test suite. Add a test case that makes a request to
/_next/data/[buildId]/[page].jsonon a Pages Router app and asserts it returns JSON with the correctpageProps. Confirm it fails before implementing the fix.Implement a
_next/dataroute handler inserver/prod-server.ts. Intercept requests matching/_next/data/[buildId]/[page].json, extract the page path, call the page'sgetServerSideProps/getStaticProps, and return the result as{ pageProps: ... }JSON.Implement URL normalization in the middleware pipeline. Before passing requests to middleware, strip the
/_next/data/[buildId]/prefix and.jsonsuffix so middleware sees the canonical page path (e.g.,/send-url/instead of/_next/data/.../send-url.json).Check dev/prod parity. Ensure
server/dev-server.tsalso handles data requests consistently.