Redirect function in server action ignores "replace" parameter #70216
Labels
bug
Issue was opened via the bug report template.
Documentation
Related to Next.js' official documentation.
locked
Navigation
Related to Next.js linking (e.g., <Link>) and navigation.
Link to the code that reproduces this issue
https://stackblitz.com/edit/stackblitz-starters-c5ngbj?file=app%2Fpage.tsx
To Reproduce
Current vs. Expected behavior
The form is submitting a server action that calls
redirect()
function with url pointing back to the main page andRedirectType.replace
to replace the current URL in the browser history stack.Current behavior:
After submitting the form and pressing go back button or browser's back button, browser navigates me back to the Child page (where form was submitted).
Expected behaviour:
Browser should not navigate to the Child page, instead should stay where it is ("/") as
redirect
has property type set toreplace
.Provide environment information
Operating System: Platform: linux Arch: x64 Version: Ubuntu 20.04.0 LTS Wed Sep 18 2024 14:52:46 GMT+0200 (Central European Summer Time) Available memory (MB): NaN Available CPU cores: 8 Binaries: Node: 18.20.3 npm: 10.2.3 Yarn: 1.22.19 pnpm: 8.15.6 Relevant Packages: next: 14.2.5 // There is a newer version (14.2.12) available, upgrade recommended! eslint-config-next: 14.2.5 react: 18.3.1 react-dom: 18.3.1 typescript: 5.2.2 Next.js Config: output: N/A
Which area(s) are affected? (Select all that apply)
Documentation, Navigation
Which stage(s) are affected? (Select all that apply)
next dev (local), next build (local), next start (local), Vercel (Deployed), Other (Deployed)
Additional context
I also tested this on Next.js 15 and could reproduce the bug.
The text was updated successfully, but these errors were encountered: