Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[next]: skip action rewrite if RSC header is present #11576

Merged
merged 3 commits into from
May 10, 2024

Conversation

ztanner
Copy link
Member

@ztanner ztanner commented May 10, 2024

When rewriting requests that contain a next-action header to a .action output, we should do so only in the case where the RSC header isn't present. When a Next.js server action triggers a redirect, an intra-app RSC request will be made to that requested URL, with the next-action header still present. This means the intra-app request will be incorrectly rewritten, when we only intended to handle the actual action request.

This was patched in Next.js in the following PR:

But it seems like a good idea to be resilient to this here as well.

Copy link

changeset-bot bot commented May 10, 2024

🦋 Changeset detected

Latest commit: e88583c

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

@@ -1956,14 +1956,20 @@ export async function serverBuild({
// Also includes separate handling for index routes which should match to /index.action.
// This follows the same pattern as the rewrites for .rsc files.
{
src: `^${path.posix.join('/', entryDirectory, '/')}`,
src: `^${path.posix.join('/', entryDirectory, '/?')}`,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated to the core change here, but I updated this to match the same change for RSC handling in this PR, since it seems relevant to both cases:

@ztanner ztanner added pr: automerge Automatically merge the PR when checks pass and removed pr: automerge Automatically merge the PR when checks pass labels May 10, 2024
@kodiakhq kodiakhq bot merged commit 18d1703 into main May 10, 2024
110 checks passed
@kodiakhq kodiakhq bot deleted the fix/skip-rsc-for-action-rewrite branch May 10, 2024 21:09
EndangeredMassa pushed a commit that referenced this pull request May 11, 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.1.0

### Minor Changes

- Update pnpm version detection logic
([#11445](#11445))
    Add support for pnpm 9

## vercel@34.1.11

### Patch Changes

- Updated dependencies
\[[`5014b1e82`](5014b1e),
[`18d1703d5`](18d1703),
[`e87d4c14d`](e87d4c1),
[`bc5fd4115`](bc5fd41)]:
    -   @vercel/build-utils@8.1.0
    -   @vercel/next@4.2.10
    -   @vercel/redwood@2.0.9
    -   @vercel/remix-builder@2.1.6
    -   @vercel/node@3.1.1
    -   @vercel/static-build@2.5.5

## @vercel/client@13.2.3

### Patch Changes

- Updated dependencies
\[[`5014b1e82`](5014b1e)]:
    -   @vercel/build-utils@8.1.0

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

### Patch Changes

- Updated dependencies
\[[`5014b1e82`](5014b1e)]:
    -   @vercel/build-utils@8.1.0

## @vercel/next@4.2.10

### Patch Changes

- skip action rewrites for RSC requests
([#11576](#11576))

- Bump `@vercel/nft@0.27.0`
([#11580](#11580))

## @vercel/node@3.1.1

### Patch Changes

- Bump `@vercel/nft@0.27.0`
([#11580](#11580))

- Updated dependencies
\[[`5014b1e82`](5014b1e)]:
    -   @vercel/build-utils@8.1.0

## @vercel/redwood@2.0.9

### Patch Changes

- Bump `@vercel/nft@0.27.0`
([#11580](#11580))

## @vercel/remix-builder@2.1.6

### Patch Changes

- Bump `@vercel/nft@0.27.0`
([#11580](#11580))

- Update `@remix-run/dev` fork to v2.9.2-patch.2
([#11582](#11582))

## @vercel/static-build@2.5.5

### Patch Changes

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

## @vercel-internals/types@1.0.32

### Patch Changes

- Updated dependencies
\[[`5014b1e82`](5014b1e)]:
    -   @vercel/build-utils@8.1.0

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
pr: automerge Automatically merge the PR when checks pass
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants