Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added note about why Next.js used 307 and 308 status codes #35325

Merged
merged 3 commits into from Mar 19, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/api-reference/next.config.js/redirects.md
Expand Up @@ -44,6 +44,9 @@ module.exports = {
- `source` is the incoming request path pattern.
- `destination` is the path you want to route to.
- `permanent` `true` or `false` - if `true` will use the 308 status code which instructs clients/search engines to cache the redirect forever, if `false` will use the 307 status code which is temporary and is not cached.

> **Why does Next.js use 307 and 308?** Traditionally a 302 was used for a temporary redirect, and a 301 for a permanent redirect, but many browsers changed the request method of the redirect, from a `POST` to a `GET` request, regardless of the method used by the origin. For example, a `POST` request to `/users` to create a new user, and while using a temporary 302, would change the request method to `GET`. Next.js uses the 307 temporary redirect, and 308 permanent redirect status codes, and will preserve the request methods used.
ijjk marked this conversation as resolved.
Show resolved Hide resolved

- `basePath`: `false` or `undefined` - if false the basePath won't be included when matching, can be used for external rewrites only.
- `locale`: `false` or `undefined` - whether the locale should not be included when matching.
- `has` is an array of [has objects](#header-cookie-and-query-matching) with the `type`, `key` and `value` properties.
Expand Down