rsnext/docs
Zack Tanner eafaba39cb
update status codes for redirect and permanentRedirect in action handlers (#58885)
### 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)
2023-11-29 08:35:50 +00:00
..
01-getting-started docs: update installation section (#58555) 2023-11-16 21:39:18 -06:00
02-app update status codes for redirect and permanentRedirect in action handlers (#58885) 2023-11-29 08:35:50 +00:00
03-pages docs: patch upgrade guide to pin install version (#58993) 2023-11-29 08:26:03 +00:00
04-architecture docs: improve non-encrypted HTTP conn to a secure (#57998) 2023-11-03 14:51:01 -05:00
05-community Update 01-contribution-guide.mdx: Fix a typo (#56665) 2023-10-10 15:15:13 +00:00
index.mdx docs: Rewrite Rendering Section and React Essentials Page (#51579) 2023-08-24 08:48:44 -05:00