-
Notifications
You must be signed in to change notification settings - Fork 27k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Honor redirect type in server actions (#70279)
Fixes #70216 ### What? The `redirect` function from `next/navigation` does not honor the redirect type when used in server actions. When setting `type` to `replace`, the server action pushes to history instead of replacing the route. This stems from #54458 ### Why? The server action should honor the redirect type. ### How? By setting `x-action-redirect` header to `<url>;<redirectType>`, we extract the type of redirect to be performed on the client. This is handled in a way that if the type is absent, we fallback to `push`. Demo: https://github.com/user-attachments/assets/3c84c6e3-2b08-4df3-89b2-5f9d290cc5ff Observe that once the form is submitted and the action replaced the URL with `/`, we didn't go back to the `/child` route. --------- Co-authored-by: Zack Tanner <1939140+ztanner@users.noreply.github.com>
- Loading branch information
Showing
6 changed files
with
74 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters