eafaba39cb
### What? Calling `redirect` or `permanentRedirect` with a route handler used by a server action will result in that POST request following the redirect. This could result in unexpected behavior, such as re-submitting an action (in the case where the redirected URL makes use of the same server action). ### Why? By spec, 307 and 308 status codes will attempt to reuse the original request method & body on the redirected URL. ### How? In all cases when calling a `redirect` handler inside of an action, we'll return a `303 See Other` response which is a typical status code when redirecting to a success / confirmation page as a result of a POST/PUT. The other option would be to use 301 / 302 status codes, but since we're already doing a 303 status code [here](https://github.com/vercel/next.js/blob/canary/packages/next/src/server/app-render/action-handler.ts#L603), this aligns the behavior for the route handler case. Closes NEXT-1733 See also: https://github.com/vercel/next.js/issues/51592#issuecomment-1810212676 [Slack x-ref](https://vercel.slack.com/archives/C03S8ED1DKM/p1700060786749079) |
||
---|---|---|
.. | ||
01-getting-started | ||
02-app | ||
03-pages | ||
04-architecture | ||
05-community | ||
index.mdx |