fix: don't do permanent redirects in dev mode #12533
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
DESCRIBE YOUR PR
yarn dev:developer-docs
starts a nextJs devServer on localhost:3000/, which immediately yields a 301 - Permanent Redirect to localhost:3000/getting-started/since Permanent Redirects get cached by the browser, all other projects that start a devserver on localhost:3000 will then redirect to /getting-started/, which likely doesn't exist.
Since port 3000 is a popular port to be used in development, this permanent redirect can interfere with other projects, which is not a great DX (ask me how I know 😂 ).
This fix changes redirects to HTTP Status Code 302 in development mode, which is a temporary redirect that doesn't get cached by browsers; in production, it's still fine to issue 301, as caching by the browser will make the redirect faster
IS YOUR CHANGE URGENT?
Help us prioritize incoming PRs by letting us know when the change needs to go live.
SLA
Thanks in advance for your help!
PRE-MERGE CHECKLIST
Make sure you've checked the following before merging your changes:
EXTRA RESOURCES