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

fix: don't do permanent redirects in dev mode #12533

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

TkDodo
Copy link

@TkDodo TkDodo commented Jan 31, 2025

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.

  • Urgent deadline (GA date, etc.):
  • Other deadline:
  • None: Not urgent, can wait up to 1 week+

SLA

  • Teamwork makes the dream work, so please add a reviewer to your PRs.
  • Please give the docs team up to 1 week to review your PR unless you've added an urgent due date to it.
    Thanks in advance for your help!

PRE-MERGE CHECKLIST

Make sure you've checked the following before merging your changes:

  • Checked Vercel preview for correctness, including links
  • PR was reviewed and approved by any necessary SMEs (subject matter experts)
  • PR was reviewed and approved by a member of the Sentry docs team

EXTRA RESOURCES

`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.

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
Copy link

vercel bot commented Jan 31, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
develop-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 31, 2025 10:42am
sentry-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 31, 2025 10:42am
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
changelog ⬜️ Ignored (Inspect) Visit Preview Jan 31, 2025 10:42am

@TkDodo TkDodo requested a review from JonasBa January 31, 2025 10:15
Copy link

codecov bot commented Jan 31, 2025

Bundle Report

Changes will decrease total bundle size by 15 bytes (-0.0%) ⬇️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
sentry-docs-server-cjs 10.64MB -9 bytes (-0.0%) ⬇️
sentry-docs-client-array-push 9.31MB -6 bytes (-0.0%) ⬇️

Affected Assets, Files, and Routes:

view changes for bundle: sentry-docs-server-cjs

Assets Changed:

Asset Name Size Change Total Size Change (%)
1729.js -3 bytes 1.63MB -0.0%
../instrumentation.js -3 bytes 965.23kB -0.0%
9523.js -3 bytes 941.45kB -0.0%
view changes for bundle: sentry-docs-client-array-push

Assets Changed:

Asset Name Size Change Total Size Change (%)
static/chunks/pages/_app-*.js -3 bytes 866.04kB -0.0%
static/chunks/9557-*.js -3 bytes 391.11kB -0.0%
server/middleware-*.js -5.55kB 1.0kB -84.74%
server/middleware-*.js 5.55kB 6.55kB 555.3% ⚠️
static/4wKtCWpGXms_4ZIwQBorX/_buildManifest.js (New) 578 bytes 578 bytes 100.0% 🚀
static/4wKtCWpGXms_4ZIwQBorX/_ssgManifest.js (New) 77 bytes 77 bytes 100.0% 🚀
static/DlCEhMr8RZ3jLJAzjni6w/_buildManifest.js (Deleted) -578 bytes 0 bytes -100.0% 🗑️
static/DlCEhMr8RZ3jLJAzjni6w/_ssgManifest.js (Deleted) -77 bytes 0 bytes -100.0% 🗑️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant