mirror of
https://github.com/cloudflare/vinext.git
synced 2026-05-09 00:09:23 +02:00
[PR #779] [MERGED] fix: default redirect() to "push" in Server Action context #839
Labels
No labels
enhancement
enhancement
good first issue
help wanted
nextjs-tracking
nextjs-tracking
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/vinext#839
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/cloudflare/vinext/pull/779
Author: @NathanDrake2406
Created: 4/4/2026
Status: ✅ Merged
Merged: 4/4/2026
Merged by: @james-elicx
Base:
main← Head:fix/server-action-redirect-type📝 Commits (1)
df4b44afix: default redirect() to "push" in Server Action context📊 Changes
5 files changed (+140 additions, -18 deletions)
View changed files
📝
packages/vinext/src/entries/app-rsc-entry.ts(+5 -2)📝
packages/vinext/src/shims/navigation.ts(+21 -3)📝
tests/__snapshots__/entry-templates.test.ts.snap(+30 -12)📝
tests/app-router.test.ts(+18 -0)📝
tests/shims.test.ts(+66 -1)📄 Description
Summary
redirect()called inside a Server Action always used"replace"navigation, breaking the Back button after form submissions. Next.js defaults to"push"in action context (viaactionAsyncStorage.getStore()?.isAction)."push", while SSR render contexts only extractlocation/statusCode(no type needed at HTTP level).typeparameter topermanentRedirect()matching the Next.js signature (defaults to"replace").How it works
redirect("/foo")now produces digestNEXT_REDIRECT;;%2Ffoo(empty type field)redirect("/foo", "push")producesNEXT_REDIRECT;push;%2Ffoo(explicit, always respected)app-rsc-entry.tsresolves empty to"push"(parts[1] || "push")x-action-redirect-typeheader and useswindow.location.assign()for push /window.location.replace()for replaceNext.js reference
packages/next/src/client/components/redirect.ts— line 43:type ??= actionAsyncStorage?.getStore()?.isAction ? 'push' : 'replace'packages/next/src/client/components/redirect.ts— line 62:permanentRedirectaccepts optionaltypeparameterTest plan
redirect()without explicit type produces empty sentinel in digestredirect()with explicit"push"or"replace"preserves type in digestpermanentRedirect()accepts optionaltypeparameterpermanentRedirect()defaults to"replace"when no type given"push"(template assertion)🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.