cloudflare/vinext

App Router + Pages Router API endpoints: `pages/api/*` unreachable from app-dir suite

Geschlossen

#1.520 geöffnet am 22.05.2026

 (0 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)TypeScript (385 Forks)github user discovery
adapter-api-e2ehelp wanted

Repository-Metriken

Stars
 (8.633 Sterne)
PR-Merge-Metriken
 (Durchschn. Merge 1T 1h) (462 gemergte PRs in 30 T)

Beschreibung

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-22).

Problem

When an App Router app coexists with Pages Router pages/api/* endpoints (e.g., /api/dump-headers-serverless, /api/dump-headers-edge), vinext serves an HTML This page could not be found page instead of executing the API route. This breaks middleware-driven request-header inspection tests for both serverless and edge runtimes and also breaks draft-mode flows that rely on the Pages API endpoint.

FetchError: invalid json response body at .../api/dump-headers-serverless reason: Unexpected token 'T', "This page "...
FetchError: invalid json response body at .../api/dump-headers-edge

Estimated Impact

~8 test failures across the deploy suite.

Affected Test Suites

  • test/e2e/app-dir/app-middleware/app-middleware.test.ts (8 failures)

Recommendation

  1. Reproduce first in vinext's own test suite. Add a fixture with both app/ and pages/api/* and assert the API routes return JSON.

  2. Make the router dispatch fall through to pages/api/*. When the App Router does not match a request, the dispatcher must try Pages Router API routes before serving the not-found page.

  3. Cover the draft-mode test paths. The same fix should restore the draft-mode flow that POSTs to the Pages API endpoint.


Part of #1328.

Contributor Guide