cloudflare/vinext

i18n routing: `locale: false` on rewrites/redirects not implemented

已關閉

#1,336 建立於 2026年5月20日

 (1 則留言) (0 個反應) (0 位負責人)TypeScript (383 個分叉)github user discovery
adapter-api-e2ehelp wanted

倉庫指標

星標
 (8,624 顆星)
PR 合併指標
 (平均合併 1天 1小時) (30 天內合併 462 個 PR)

描述

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

Several i18n routing features are not properly implemented:

  1. locale: false on rewrite/redirect sources not implemented. When a rewrite or redirect in next.config.js specifies locale: false on the source, the pattern should match the raw path without locale prefix handling. vinext does not honor this flag, so rewrites/redirects fail to match when they should.

  2. Locale detection re-runs on every request instead of being sticky. After the initial locale is established, client-side navigations should preserve it. vinext appears to re-detect from Accept-Language on each server request, causing the locale to flip unexpectedly.

  3. Locale prefix not stripped for API routes. Requests like /fr/api/ok need the locale prefix stripped before API route matching. vinext does not strip it, causing 404s.

  4. Default locale prefix stripping missing. Requests to /en/page (where en is the default locale) should redirect to /page. This redirect is not happening.

Expected: "en"
Received: "id"  // locale flipped to browser preference on client nav

Estimated Impact

~24 test failures across the deploy suite.

Affected Test Suites

  • test/e2e/i18n-ignore-rewrite-source-locale/rewrites.test.ts (8 failures, all 8 tests)
  • test/e2e/i18n-ignore-redirect-source-locale/redirects-with-basepath.test.ts (4 failures)
  • test/e2e/i18n-ignore-redirect-source-locale/redirects.test.ts (4 failures)
  • test/e2e/ignore-invalid-popstateevent/with-i18n.test.ts (3 failures)
  • test/e2e/ignore-invalid-popstateevent/without-i18n.test.ts (2 failures)
  • test/e2e/i18n-preferred-locale-detection/i18n-preferred-locale-detection.test.ts (1 failure)
  • test/e2e/i18n-default-locale-redirect/i18n-default-locale-redirect.test.ts (1 failure)
  • test/e2e/middleware-custom-matchers-i18n/test/index.test.ts (1 failure)

Recommendation

  1. Reproduce first in vinext's own test suite. Add tests for: (a) a rewrite with locale: false source matching a non-locale-prefixed path, (b) locale persistence across client navigations, (c) API routes under locale prefixes. Confirm they fail.

  2. Study Next.js i18n implementation. Search .nextjs-ref/packages/next/src/server/ for locale: false, locale detection, and locale stripping logic.

  3. Implement locale: false flag. When evaluating rewrite/redirect sources with locale: false, skip the locale prefix injection and match against the raw path.

  4. Make locale detection sticky. Once a locale is established (either by URL prefix or initial detection), it should be preserved across navigations. The locale context should be carried in the client-side router state.

  5. Strip locale prefix for API routes. Add locale stripping before the API route matching step.

貢獻者指南