AI & Agent Dev Bug Sandbox logo
AI & Agent Dev Bug Sandbox
Back to Radar

@Next/Routing Generates Locale-Prefixed Regex For Dynamic API Routes, Causing 404 When I18n Is On

Dynamic API routes like /api/blog/[slug] become unreachable without a locale prefix when i18n is configured. The generated sourceRegex incorrectly requires a locale segment, while API routes should not be localized.

highConfidence 90%Next.jsHydrationTurbopackServer ActionsAffected V16.3.1-Canary.16Affected V16.5.0-Canary.4

Origin Analysis

The route normalization for i18n treats dynamic API routes as localized pages and inserts a required locale segment into the source regex and destination, violating Next.js behavior where API routes are not locale-prefixed.
1. pnpm install 2. pnpm build (adapter.mjs saves onBuildComplete routing to routing.json) 3. pnpm check (resolves requests with @next/routing and that routing) Observe /api/blog/first returns 404 while /fr/api/blog/first matches.

Fixing Code Block

Edge Case Audit

This mutates build output and must be re-applied after every build. It assumes routing.json structure remains stable across Next.js versions; upgrades may change the regex pattern and break the replacement. Run this script single-threaded after build to avoid concurrent write corruption. Rollback by restoring the original routing.json from backup. Once an official fix is released, remove this workaround.

Ecosystem Topology

Agent Frameworks

LangChain, LlamaIndex, and Pydantic

  1. highProperty graph relation keys collide when entity IDs or labels contain underscores
  2. highCodeActAgent drops assistant tool-call metadata during handoff, leaving an orphan tool response
  3. high[Bug]: HierarchicalNodeParser async methods return the documents unsplit
  4. highLLM.predict_and_call fails with ValidationError for non-function-calling models when react_chat_formatter is omitted
  5. highAnthropic streaming server-tool input_json_delta overwrites completed client tool_use arguments due to stale cur_tool_call state