Skip to content

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

Merged
kodiakhq[bot] merged 6 commits intomainfrom
zt/more-rewrite-fixes
Jun 6, 2024
Merged

[next]: fix issues with rewrite normalization of index routes#11707
kodiakhq[bot] merged 6 commits intomainfrom
zt/more-rewrite-fixes

Conversation

@ztanner
Copy link
Member

@ztanner ztanner commented Jun 6, 2024

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.

@changeset-bot
Copy link

changeset-bot bot commented Jun 6, 2024

🦋 Changeset detected

Latest commit: fb3a90b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@vercel/next Patch
vercel Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Co-authored-by: JJ Kasper <jj@jjsweb.site>
ijjk
ijjk previously approved these changes Jun 6, 2024
Co-authored-by: JJ Kasper <jj@jjsweb.site>
ijjk
ijjk previously approved these changes Jun 6, 2024
@kodiakhq kodiakhq bot merged commit fa9789a into main Jun 6, 2024
@kodiakhq kodiakhq bot deleted the zt/more-rewrite-fixes branch June 6, 2024 23:15
EndangeredMassa pushed a commit that referenced this pull request Jun 7, 2024
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.


# Releases
## @vercel/build-utils@8.2.2

### Patch Changes

- Change node 16.x EOL for Vercel
([#11704](#11704))

- Improve error message and refactor
([#11706](#11706))

- [built-utils] Handle case of not having lockfile when corepack is
enabled ([#11697](#11697))

## vercel@34.2.6

### Patch Changes

- [built-utils] Handle case of not having lockfile when corepack is
enabled ([#11697](#11697))

- Updated dependencies
\[[`5c12ed695`](5c12ed6),
[`21444a38e`](21444a3),
[`fa9789a93`](fa9789a),
[`c925dc4a1`](c925dc4),
[`06d2d860e`](06d2d86),
[`b735f37fd`](b735f37)]:
    -   @vercel/build-utils@8.2.2
    -   @vercel/next@4.2.16
    -   @vercel/redwood@2.0.10
    -   @vercel/remix-builder@2.1.7
    -   @vercel/node@3.1.7
    -   @vercel/static-build@2.5.11

## @vercel/client@13.2.9

### Patch Changes

- Updated dependencies
\[[`5c12ed695`](5c12ed6),
[`21444a38e`](21444a3),
[`06d2d860e`](06d2d86)]:
    -   @vercel/build-utils@8.2.2

## @vercel/gatsby-plugin-vercel-builder@2.0.33

### Patch Changes

- Updated dependencies
\[[`5c12ed695`](5c12ed6),
[`21444a38e`](21444a3),
[`06d2d860e`](06d2d86)]:
    -   @vercel/build-utils@8.2.2

## @vercel/next@4.2.16

### Patch Changes

- prevent /index from being incorrectly normalized in rewrites
([#11707](#11707))

- Upgrade to @vercel/nft 0.27.2 with browser remapping support
([#11700](#11700))

- ensure unmatched rsc rewrites are routed to correct handler
([#11688](#11688))

## @vercel/node@3.1.7

### Patch Changes

- Upgrade to @vercel/nft 0.27.2 with browser remapping support
([#11700](#11700))

- Updated dependencies
\[[`5c12ed695`](5c12ed6),
[`21444a38e`](21444a3),
[`06d2d860e`](06d2d86)]:
    -   @vercel/build-utils@8.2.2

## @vercel/redwood@2.0.10

### Patch Changes

- Upgrade to @vercel/nft 0.27.2 with browser remapping support
([#11700](#11700))

## @vercel/remix-builder@2.1.7

### Patch Changes

- Upgrade to @vercel/nft 0.27.2 with browser remapping support
([#11700](#11700))

## @vercel/static-build@2.5.11

### Patch Changes

-   Updated dependencies \[]:
    -   @vercel/gatsby-plugin-vercel-builder@2.0.33

## @vercel-internals/types@1.0.38

### Patch Changes

- Updated dependencies
\[[`5c12ed695`](5c12ed6),
[`21444a38e`](21444a3),
[`06d2d860e`](06d2d86)]:
    -   @vercel/build-utils@8.2.2

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants