[next]: fix issues with rewrite normalization of index routes (#11707)

The Next.js builder currently normalizes user rewrites to ensure the internal `.rsc` / `.action` rewrites are still handled even after following the rewrite.

However we have special rewrites: `/index.rsc` and `/index.action`. When those routes pass through the normalization logic, a request routed to a catch-all route (e.g. `[[...param]]`) will go from `/` -> `/index.rsc` -> `<someRewriteString>?param=index`. This is inconsistent `next start` or other spots where the param should be an empty string.

Similarly, if a user rewrites their entire app to a subdirectory (eg `/:path*` -> `/base/:path*`, a route will go from `/` -> `/index.rsc` -> `/base/index.rsc` which won't exist, causing a 404. 

The solution here is to return the `index.rsc` / `index.action` routes back to `/` so they can be handled by user rewrites, if necessary. 

This also disables the `hasActionOutputSupport` flag if `routesManifest.i18n` is detected as they are not compatible.
This commit is contained in:
Zack Tanner
2024-06-06 16:15:47 -07:00
committed by GitHub
parent 5c12ed6950
commit fa9789a93e
18 changed files with 273 additions and 2 deletions

View File

@@ -0,0 +1,5 @@
---
'@vercel/next': patch
---
prevent /index from being incorrectly normalized in rewrites