fix(pages): normalize data routes for trailing slash middleware - #2470
Conversation
|
/bigbonk review for issues |
commit: |
|
Review: fix(pages): normalize data routes for trailing slash middlewareReviewed all 8 changed files for correctness, dev/prod parity, and Next.js behavior. The change is solid and I found no blocking issues. Details below. What was verifiedCorrectness of the core helper
Dev/prod parity (all four request paths updated)
No downstream regressions in the no-middleware case
Generated-entry template hoisting Non-blocking observation (pre-existing, not introduced here)
Validation performed locally
LGTM. |
|
Review posted to PR #2470. Summary of findings: No blocking issues foundThe change correctly threads Key verifications:
One non-blocking observation: a pre-existing fallback at Local validation: 64 tests passed, |
|
/bigbonk review for issues |
Review: fix(pages): normalize data routes for trailing slash middlewareRe-reviewed at commit The gating commit is a genuine parity fix (verified against Next.js source)The earlier review verified un-gated (always-on) normalization. The follow-up commit gates it on middleware presence. I confirmed this matches Next.js exactly. In // ensure trailing slash is normalized per config
if (middleware) {
if (this.nextConfig.trailingSlash && !pathname.endsWith('/')) {
pathname += '/'
}
if (!this.nextConfig.trailingSlash && pathname.length > 1 && pathname.endsWith('/')) {
pathname = pathname.substring(0, pathname.length - 1)
}
}Next.js only touches the data-request pathname's trailing slash when middleware is present. The un-gated version (commit 1) would have diverged for no-middleware apps; the gate fixes that. The new Middleware-presence signal is consistent across all four pathsEach path gates on the correct, equivalent signal:
|
|
Review posted to PR #2470. Summary: No blocking issues foundI re-reviewed at commit Key finding — the gating commit is a genuine parity fix. I verified against Next.js Verified correctness:
Two non-blocking, pre-existing gaps (not regressions): the |
|
Deploy-suite run 28478866791 / report job 84413308650 triage: this PR appears to cover the Pages middleware trailing-slash/data-route behavior rows from Exact rows:
Since this PR is already James-owned, I am skipping duplicate implementation work for these rows. |
Performance benchmarksCompared 0 improved · 0 regressed · 6 within ±1.5%
View detailed results and traces 🟢 improvement · 🔴 regression · ⚫ change below 1.5% · paired base/head |
Summary
/_next/datarequests back to trailing-slash page paths before middleware and route matching see thembasePathandtrailingSlashinto Pages data normalization across generated Pages entries, worker/page handlers, prod server, and App Router Pages fallbackNext.js parity
Next.js rebuilds
/_next/data/<buildId>/*.jsonrequests into page pathnames and, when middleware is present, appliesnextConfig.trailingSlashbefore continuing request handling. This fixes the Pages middleware trailing-slash data-request rows from deploy-suite run28478866791/ job84413308650without duplicating the rewrite-query/navigation/cache fixes already covered by sibling PRs.Run 28478866791 mapping
should trigger middleware for data requests,should add a rewrite header on data requests for rewrites, plus the dynamic/chained rewrite rows that were failing because data requests were normalized without the configured slash.Validation
vp test run tests/pages-data-route.test.ts tests/entry-templates.test.ts— 64 passedvp check packages/vinext/src/server/pages-data-route.ts packages/vinext/src/server/pages-page-handler.ts packages/vinext/src/server/prod-server.ts packages/vinext/src/server/app-rsc-handler.ts packages/vinext/src/entries/pages-server-entry.ts packages/vinext/src/index.ts tests/pages-data-route.test.ts tests/entry-templates.test.ts— passREPO="$(pwd)" NEXTJS_DIR="/Users/jamesanderson/Developer/vinext/.nextjs-ref" NEXT_TEST_CONCURRENCY=1 ./scripts/run-targeted-nextjs-e2e.sh test/e2e/middleware-general/test/index.test.ts— 60 passed, 6 failed; remaining rows mapped to fix(middleware): preserve Pages rewrite state and cache isolation #2216/fix(pages): preserve middleware rewrite navigation state #2454REPO="$(pwd)" NEXTJS_DIR="/Users/jamesanderson/Developer/vinext/.nextjs-ref" NEXT_TEST_CONCURRENCY=1 ./scripts/run-targeted-nextjs-e2e.sh test/e2e/middleware-general/test/node-runtime.test.ts— 62 passed, 6 failed; remaining rows mapped to fix(middleware): preserve Pages rewrite state and cache isolation #2216/fix(pages): preserve middleware rewrite navigation state #2454REPO="$(pwd)" NEXTJS_DIR="/Users/jamesanderson/Developer/vinext/.nextjs-ref" NEXT_TEST_CONCURRENCY=1 ./scripts/run-targeted-nextjs-e2e.sh test/e2e/middleware-rewrites/test/index.test.ts— 52 passed, 4 failed, 2 skipped; remaining rows mapped to fix(middleware): preserve Pages rewrite state and cache isolation #2216/fix(pages): align middleware data prefetch caching #2451/fix(pages): preserve middleware rewrite navigation state #2454REPO="$(pwd)" NEXTJS_DIR="/Users/jamesanderson/Developer/vinext/.nextjs-ref" NEXT_TEST_CONCURRENCY=1 ./scripts/run-targeted-nextjs-e2e.sh test/e2e/middleware-trailing-slash/test/index.test.ts— 20 passed, 3 failed; remaining rows mapped to fix(middleware): preserve Pages rewrite state and cache isolation #2216/fix(pages): preserve middleware rewrite navigation state #2454Artifacts from local deploy-suite runs were cleaned after validation.