cloudflare/vinext

Trailing slash configuration not enforced

Chiusa

#1332 aperta il 20 mag 2026

 (1 commento) (0 reazioni) (0 assegnatari)TypeScript (383 fork)github user discovery
adapter-api-e2ehelp wanted

Metriche repository

Star
 (8624 stelle)
Metriche merge PR
 (Merge medio 1g 1h) (462 PR mergiate in 30 g)

Descrizione

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 trailingSlash configuration from next.config.js is not properly enforced in several areas:

  1. Middleware redirect Location headers ignore the config. When trailingSlash: true, NextResponse.redirect(new URL('/somewhere', req.url)) should produce Location: /somewhere/ but vinext emits Location: /somewhere.

  2. No auto-redirect for missing/extra trailing slash. Requests without trailing slash should receive a 307 redirect to the trailing-slash version (when trailingSlash: true), but vinext returns 200 with the page content directly.

  3. Shallow navigation triggers full server render. URL changes via router.push(url, undefined, { shallow: true }) cause a server roundtrip instead of a client-only URL update, detectable because the server-rendered random number changes.

Expected: "/somewhere/"
Received: "/somewhere"

Expected: 307
Received: 200

Estimated Impact

~58 test failures across the deploy suite.

Affected Test Suites

  • test/e2e/trailing-slashes/with-trailing-slash.test.ts (20 failures)
  • test/e2e/trailing-slashes/without-trailing-slash.test.ts (20 failures)
  • test/e2e/middleware-trailing-slash/test/index.test.ts (14 failures)
  • test/e2e/app-dir/trailingslash/trailingslash.test.ts (3 failures)
  • test/e2e/basepath/trailing-slash.test.ts (1 failure)

Recommendation

  1. Reproduce first in vinext's own test suite. Add test cases that configure trailingSlash: true and verify: (a) requests without trailing slash get 307 redirected, (b) middleware redirect Location headers include trailing slash, (c) the inverse for trailingSlash: false. Confirm they fail.

  2. Study Next.js trailing slash handling. Search .nextjs-ref/packages/next/src/server/ for trailingSlash to understand where and how the normalization is applied.

  3. Apply trailing slash normalization at the server level. Before route matching, check the trailingSlash config and issue a 307 redirect if the URL doesn't conform.

  4. Normalize middleware redirect targets. When NextResponse.redirect() produces a Location header, apply the trailingSlash config to the target URL.

  5. Check dev/prod parity. Ensure both dev and production servers enforce the config consistently.

Guida contributor