Dynamic Pages API routes return 404 on Vercel when Pages Router i18n is enabled
OutputInternationalization (i18n)Pages RouterDynamic Routes
### Link to the code that reproduces this issue
https://github.com/adelrodriguez/nextjs-i18n-dynamic-api-repro
### To Reproduce
1. Open the public reproduction repository.
2. Use commit `b93f5cee3b789905cf27600d66fc7694f80daeb3`.
3. Deploy the repository to Vercel.
4. Use the Next.js framework preset.
5. Keep the default install command and build command.
6. Send these requests:
```bash
REPRO_URL="https://nextjs-i18n-dynamic-api-repro-cv5wg0r69-personal-0d17b53c.vercel.app"
curl -i "$REPRO_URL/api/ping"
curl -i "$REPRO_URL/api/echo/hello"
curl -i "$REPRO_URL/api/echo/%5Bslug%5D"
```
The first request returns `200`.
The second request returns `404`. The response contains this header:
```text
x-matched-path: /en/404
```
The third request returns `200`. The response body is:
```json
{"ok":true,"route":"dynamic","slug":"[slug]"}
```
The third request is a diagnostic request. It is not standard API use.
### Current vs. Expected behavior
I expect `/api/echo/hello` to match the dynamic Pages API route at `pages/api/echo/[slug].ts`.
I expect the route to return `200` and this body:
```json
{"ok":true,"route":"dynamic","slug":"hello"}
```
On Vercel, Next.js `16.3.0` returns the localized `404` page. The static Pages API route in the same deployment returns `200`.
The Vercel deployment contains a function named `api/echo/[slug]`. The encoded placeholder request starts this function. These results show that Vercel created the function but does not match a normal path segment to the function.
The local production server returns `200` for both API routes. The local production build lists `ƒ /api/echo/[slug]`.
### Provide environment information
```bash
Operating System:
Platform: darwin
Arch: arm64
Version: Darwin Kernel Version 25.6.0
Available memory (MB): 49152
Available CPU cores: 14
Binaries:
Node: 24.2.0
npm: 11.3.0
Yarn: N/A
pnpm: 11.16.0
Relevant Packages:
next: 16.3.0
eslint-config-next: N/A
react: 19.2.8
react-dom: 19.2.8
typescript: 6.0.3
Next.js Config:
output: N/A
```
### Which area(s) are affected? (Select all that apply)
Dynamic Routes, Internationalization (i18n), Pages Router, Output
### Which stage(s) are affected? (Select all that apply)
Vercel (Deployed)
### Additional context
I tested each deployed request three times. Each test gave the same result.
| Next.js | i18n | `/api/echo/hello` on Vercel | Encoded placeholder | Commit | Deployment |
| --- | --- | --- | --- | --- | --- |
| 16.2.12 | Enabled | `200` | `200` | [`bcd5da6`](https://github.com/adelrodriguez/nextjs-i18n-dynamic-api-repro/commit/bcd5da6f10107a10fafee9c62459b826c75c0c01) | [Open](https://nextjs-i18n-dynamic-api-repro-8ryra6til-personal-0d17b53c.vercel.app) |
| 16.3.0 | Enabled | `404`, matched `/en/404` | `200` | [`b93f5ce`](https://github.com/adelrodriguez/nextjs-i18n-dynamic-api-repro/commit/b93f5cee3b789905cf27600d66fc7694f80daeb3) | [Open](https://nextjs-i18n-dynamic-api-repro-cv5wg0r69-personal-0d17b53c.vercel.app) |
| 16.3.1-canary.7 | Enabled | `404`, matched `/en/404` | `200` | [`b439280`](https://github.com/adelrodriguez/nextjs-i18n-dynamic-api-repro/commit/b439280984a19594f09d23ec6e8f64c21b38efe1) | [Open](https://nextjs-i18n-dynamic-api-repro-kxrd7j8eu-personal-0d17b53c.vercel.app) |
| 16.3.0 | Disabled | `200` | `200` | [`35a3f03`](https://github.com/adelrodriguez/nextjs-i18n-dynamic-api-repro/commit/35a3f03789ec898f759284516f2691d8361d2ac2) | [Open](https://nextjs-i18n-dynamic-api-repro-jvyjugppw-personal-0d17b53c.vercel.app) |
The version tests show that the regression starts after `16.2.12` and is present in `16.3.0`. The latest canary version, `16.3.1-canary.7`, is also affected.
The control test shows that the dynamic API route works with Next.js `16.3.0` when I remove only the `i18n` configuration.
The public repository contains the full HTTP responses, the local build output, the `next info` output, and the Vercel function lists.
The earlier report is #96931. An automated check closed it because it did not contain a public reproduction link.
PR #94905 and commit `668cd3a4a7da71e4402abf9a818e89e0476f275e` changed adapter i18n handling for Pages API routes in this version range. This change is an investigation lead. The reproduction does not prove that this change caused the regression.
0 条评论