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

docs: Add some App Router FAQs #55186

Merged
merged 4 commits into from Sep 12, 2023
Merged

docs: Add some App Router FAQs #55186

merged 4 commits into from Sep 12, 2023

Conversation

leerob
Copy link
Member

@leerob leerob commented Sep 10, 2023

Based on questions I've seen in issues and discussions.

Copy link

@orca-security-us orca-security-us bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Orca Security Scan Summary

Status Check Issues by priority
Passed Passed Secrets high 0   medium 1   low 0   info 0 View in Orca

leerob and others added 2 commits September 10, 2023 11:30
Co-authored-by: Balázs Orbán <info@balazsorban.com>
Copy link
Contributor

@mayank1513 mayank1513 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great!

@kodiakhq kodiakhq bot merged commit 6e3c4e2 into canary Sep 12, 2023
99 of 101 checks passed
@kodiakhq kodiakhq bot deleted the app-router-faq branch September 12, 2023 19:45
@GabenGar
Copy link
Contributor

It looks like the redirect functions are hardcoded to 307/308 redirects. How do you do 301/302/303 redirects then?

@leerob
Copy link
Member Author

leerob commented Sep 13, 2023

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 to GET, regardless of the original method. For example, if the browser made a request to POST /v1/users which returned status code 302 with location /v2/users, the subsequent request might be GET /v2/users instead of the expected POST /v2/users. Next.js uses the 307 temporary redirect, and 308 permanent redirect status codes to explicitly preserve the request method used.

From the docs 🙏

@GabenGar
Copy link
Contributor

Yeah but there might be use cases for when you want to change the method to GET and 301/302/303 are go-to SEO redirects (SEO doesn't operate outside of GET requests anyway). I have a suspicion some search engines can choke on 307/308 by assuming these are invalid codes.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 30, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants