A minimal demonstration of redirect() inside a server action can't switch between root layouts in next.js 14
Corresponding issue report: vercel/next.js#58263
- start the development server with
npm run dev
- Open http://localhost:3000/en in your browser
- Click on the "search" submit button on top of the page next to the text input (it doesn't matter what you enter into the textfield, it always redirects to the same route)
You should land on /en/search/hello
as that is the hardcoded redirection inside the server action in services/SiteSearch.service.ts
.
This was the behavior in Next.js 13.4.12
, but it also threw an error (see vercel/next.js#53392)
The server action sends back a redirect instruction among the response headers:
X-Action-Redirect: /en/search/hello
but the page does not go to that path
- start the development server with
npm run dev
- Open http://localhost:3000/en/search/world in your browser
- Click on the submit button as in the previous scenario
The page should get redirected to /en/search/hello
The page does get redirected to /en/search/hello