Skip to content

Keep docs on ms-docs.sg.dev instead of sending visitors to sourcegraph.com - #2168

Open
enriquegh wants to merge 2 commits into
mainfrom
enrique/ms-docs-domain
Open

enriquegh wants to merge 2 commits into
mainfrom
enrique/ms-docs-domain

Conversation

@enriquegh

Copy link
Copy Markdown
Contributor

Morgan Stanley's proxy (Netskope) blocks sourcegraph.com, so their users can't open sourcegraph.com/docs. As a short-term workaround the production deployment is also served from ms-docs.sg.dev (their instance is ms.sg.dev). This PR keeps visitors on that host instead of sending them back to sourcegraph.com, and keeps it out of search indexes. Background: https://sourcegraph.slack.com/archives/C01DXLN3D0T/p1794592592148349

Changes

  • vercel.json: the X-Robots-Tag: noindex, nofollow host rule for versioned docs also matches ms-docs.sg.dev. The Cloudflare robots.txt worker only covers *.sourcegraph.com. ms-docs.sg.dev/robots.txt returns 404, so crawlers can still fetch pages and see the noindex, and canonical URLs already point at https://sourcegraph.com/docs/....
  • src/proxy.ts: /v/<latest>[/…] and /@<latest>[/…] redirected to a hardcoded https://sourcegraph.com/docs; they now drop the version and stay on the request's host and basePath.
  • VersionSelector: the production build (basePath /docs) uses its bundled version list instead of fetching https://sourcegraph.com/docs/api/versions, which is the same list, is blocked for these users, and would point "latest" at sourcegraph.com. Preview and versioned builds still fetch it.
  • CustomLink: MDX links to https://sourcegraph.com/docs/... render as internal links. Most come from generated pages (CLI reference, dashboards, telemetry).

Already fine on the new host: / redirects to /docs on the same host (next.config.js), redirects from redirects.ts send relative Locations, assets are relative, and Algolia accepts any Referer, with hit URLs already rewritten to the current host.

Still on sourcegraph.com, with nothing on this site to point at instead: the Changelog/RSS/Pricing links, /docs/changelog.rss, about 90 redirects.ts entries to handbook/pricing/changelog pages, links to sourcegraph.com/search, and older versions on X.Y.sourcegraph.com.

Deployment dependencies

  • Infra CNAME ms-docs.sg.dev → cname.vercel-dns.com, DNS-only (separate infrastructure PR).
  • Add ms-docs.sg.dev to the Vercel project as a Production domain (no git branch, not a redirect), and check that Deployment Protection and Firewall rules don't block it.
  • NEXT_PUBLIC_DOCS_VERSIONS_URL must not be set for Production.

Test plan

  • VERCEL_ENV=production pnpm run build + next start, curled with Host: ms-docs.sg.dev and Host: sourcegraph.com: both give relative redirects (/ → /docs, /docs/v/8.2/admin/config → /docs/admin/config; /docs/v/8.1/admin → https://8.1.sourcegraph.com/admin), pages 200, unknown paths 404. Production today sends /docs/v/8.2 to https://sourcegraph.com/docs.
  • Chromium on https://ms-docs.sg.dev mapped to the local build, with https://sourcegraph.com/** blocked: root, version menu, search, a CLI reference link, and the 8.2 redirect stayed on the host; the HAR had 0 requests to sourcegraph.com.
  • Preview build (basePath '') with Host: 8.3.sourcegraph.com: / serves and /v/8.2/admin/config → /admin/config.
  • tsc --noEmit and eslint pass. The vercel.json header can only be checked on a Vercel deployment.

Amp thread: https://ampcode.com/threads/T-01a1d87e-2c3b-7242-bfb4-cb53bd8dc153

…h.com

Morgan Stanley's proxy blocks sourcegraph.com, so the production docs are
also served from ms-docs.sg.dev.

- Mark ms-docs.sg.dev noindex, like the versioned docs domains.
- Redirect latest-version paths (/v/X.Y, /@X.Y) on the same host.
- Use the bundled version list in production instead of fetching it
  from sourcegraph.com.
- Render links to https://sourcegraph.com/docs/... as internal links.

Amp-Thread-ID: https://ampcode.com/threads/T-01a1d87e-2c3b-7242-bfb4-cb53bd8dc153
Co-authored-by: Amp <amp@ampcode.com>
@vercel

vercel Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
sourcegraph-docs Ignored Ignored Preview Nov 16, 2026 7:10pm UTC

Request Review

@github-actions

Copy link
Copy Markdown
Contributor

@github-actions

This comment has been minimized.

This branch was successfully deployed

1 active (outdated) deployment
Preview — d637c8ba Deployed Nov 16, 2026 by vercel[bot]
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