site: Redirect / to /docs on production deployments - #1955
Merged
Conversation
With basePath=/docs nothing serves /, so the *.vercel.app deployment URL that Vercel's Slack and GitHub posts link to returns a 404. Redirect it to /docs on the same host, so the visitor sees that exact deployment. Preview deployments (no basePath) are unchanged. Amp-Thread-ID: https://ampcode.com/threads/T-01a092ad-91c8-772e-bcba-a44caabb1653 Co-authored-by: Amp <amp@ampcode.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
enriquegh
approved these changes
Sep 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
Vercel's Slack and GitHub posts for a production deploy link "Visit" to the raw deployment URL, e.g.
https://sourcegraph-docs-rmeucrf94-sourcegraph-f8c71130.vercel.app/. In productionbasePathis/docs, so nothing serves/and Vercel returns a 404. People click away thinking the deploy is broken.//docsChange
When
basePathis set, redirect/→/docson the same host (basePath: falseso the source matches the bare/). Same host, notsourcegraph.com/docs, so the visitor sees the exact deployment in the post rather than whatever is live. 307 so nothing gets cached if we change it later.Preview deployments have no
basePath, soredirects()returns[]and/keeps serving the homepage as today.sourcegraph.com never proxies
/to Vercel (only/docs/*), so the live site is unaffected.Also hoisted the duplicated
VERCEL_ENVternary into onebasePathconst sobasePath,NEXT_PUBLIC_DOCS_BASE_PATH, and the redirect can't drift.Verified
VERCEL_ENV=production npx next dev:Without
VERCEL_ENV:/200,/admin200, no redirect.Note
#1942 also adds a
redirectskey tonext.config.js; whichever merges second will need a one-line conflict resolution (keep both entries).