Deploy docs to Vercel reliably
When Next.js and Docusaurus share one Vercel project, routing conflicts can cause 404s. Put docs in a separate project. Add rewrites only when you need /docs/* on the app domain.
Goals
- Use
https://<docs-domain>/as the default, and keephttps://<app-domain>/docs/...only when needed. - The docs project builds and serves the Docusaurus site.
- Build/CI should fail on 404 or broken links.
Docs project (Vercel)
- Add this repo as a separate Vercel project (e.g.,
river-review-docs). - Build Command:
npm run build; Output Directory:build. - Add env vars:
DOCS_SITE_URL=https://<docs-domain>(e.g.,https://river-review-docs.vercel.app)DOCS_BASE_URL=/(optional; default is/)DOCS_ROUTE_BASE_PATH=/(optional; default is/)
- If you want
/docs/to redirect to root, keepvercel.jsonas below:
{
"trailingSlash": true,
"redirects": [{ "source": "/docs/", "destination": "/", "permanent": true }]
}
If you want /docs/ as the base path, set DOCS_BASE_URL=/docs/ and update redirects to point / -> /docs/.
If you omit DOCS_BASE_URL, the build targets GitHub Pages at /river-review/ as before.
App project (e.g., <app-domain> / river-review.the3396.com)
Add rewrites in the app vercel.json to forward /docs/* to the docs domain (docs served at /):
{
"rewrites": [
{ "source": "/docs", "destination": "https://<docs-domain>/" },
{ "source": "/docs/:path*", "destination": "https://<docs-domain>/:path*" }
]
}
Quality gates
onBrokenLinksandonBrokenMarkdownLinksare set tothrow, so broken internal links fail the build.npm run build(optionally withDOCS_BASE_URL=/docs/ DOCS_ROUTE_BASE_PATH=/) verifies the chosen output path locally.- The link checker workflow blocks PRs when external links break.