Deploy the Docs to Cloudflare (Dashboard Guide)
Step-by-step to host backend/docs as a website on Cloudflare Pages, gated by Cloudflare Access so only approved people (your team) can read it. Everything here is done from the Cloudflare dashboard — no CLI required.
There are two parts:
- Cloudflare Pages — builds and hosts the VitePress site from this repo.
- Cloudflare Access — puts a login gate in front of it (Free up to 50 users).
Why Access instead of GitHub Pages: a GitHub Free org can only publish public Pages, which anyone with the URL could read. Cloudflare Access gives you a private, login-gated site that mirrors "only our people."
Part 1 — Create the Pages project (Git-connected)
Step 1: Open Workers & Pages
- Log in at dash.cloudflare.com.
- Left sidebar → Workers & Pages.
- Click Create application → Pages tab → Connect to Git.
Step 2: Connect the repository
- Authorize Cloudflare for GitHub if prompted (org: OP-Oktivo).
- Select the repo that holds this code (
oktivo_app/oktivo-voice-app). - Click Begin setup.
Step 3: Configure build settings (the important part)
This is a monorepo, so the docs live in a subdirectory. Set:
| Setting | Value |
|---|---|
| Project name | oktivo-backend-docs (any unique name; becomes the *.pages.dev subdomain) |
| Production branch | main (or whichever branch you want live) |
| Framework preset | VitePress (or None if not listed) |
| Build command | npm run docs:build |
| Build output directory | .vitepress/dist |
| Root directory (Advanced) | backend/docs |
Root directory is the key field — it tells Cloudflare to
cd backend/docsbefore installing and building. With it set, the build command and output directory are relative tobackend/docs, so use.vitepress/dist(notbackend/docs/.vitepress/dist).
Optional environment variable (recommended for a consistent build):
- Variable:
NODE_VERSIONValue:20
Step 4: Save and Deploy
- Click Save and Deploy.
- Watch the build log. On success you get a URL like
https://oktivo-backend-docs.pages.dev. - Open it — the docs site should load (it's public for now; Part 2 locks it down).
Step 5 (optional): Only rebuild when docs change
To avoid rebuilding on every unrelated backend/app commit:
- Project → Settings → Build → Build watch paths.
- Include paths:
backend/docs/* - Save. Now pushes that don't touch
backend/docsskip the docs build.
Step 6 (optional but recommended): a nicer custom domain
- Project → Custom domains → Set up a custom domain.
- Enter e.g.
docs.oktivo.<yourdomain>(the zone must be on Cloudflare). - Cloudflare adds the DNS record automatically. Use this hostname in Part 2.
If you skip the custom domain, you can still protect the
*.pages.devURL in Part 2.
Part 2 — Lock it down with Cloudflare Access
This adds an identity gate. Visitors must sign in (Google / GitHub / email code) and match an Allow policy before they see any page. Access is deny-by-default.
Step 1: Open Zero Trust
- In the dashboard, go to Zero Trust (sidebar). First time only: pick a team name and the Free plan (supports up to 50 users, no card needed for Free).
Step 2: Add a login method (identity provider)
- Settings → Authentication → Login methods → Add new.
- Easiest to start: One-time PIN (emails a code — no IdP setup).
- Or add Google / GitHub for SSO if your team uses one.
Step 3: Create the Access application
- Access controls → Applications → Add an application.
- Choose Self-hosted.
- Application name:
Oktivo Backend Docs. - Application domain: enter the hostname from Part 1:
- the custom domain (
docs.oktivo.<yourdomain>), or - the Pages domain (
oktivo-backend-docs.pages.dev).To protect a
*.pages.devdomain you may need to add it under Settings → Custom Pages/Domains of Zero Trust; a real custom domain on a Cloudflare zone is the smoother path.
- the custom domain (
- Leave session duration at the default (e.g. 24h) or shorten it. Click Next.
Step 4: Create the Allow policy (who gets in)
- Policy name:
Allow Oktivo team. - Action: Allow.
- Add a rule under Include — pick ONE that fits how you want to define access:
- Emails ending in →
@yourcompany.com(everyone on your domain), or - Emails → an explicit list of teammate emails, or
- Login method / Identity provider → GitHub, combined with an email rule.
- Emails ending in →
- (Optional) Add Require rules to tighten further (e.g. specific country).
- Save the policy, then Next → Add application.
Access can't read GitHub repo collaborators directly. The practical equivalent of "repo access" is an email-domain rule or an explicit email allow-list that you keep in sync with the team.
Step 5: Test
- Open the docs URL in a private/incognito window.
- You should hit a Cloudflare Access login screen.
- Sign in with an allowed identity → the docs load.
- Try a non-allowed email → access is denied. Done.
How updates work after setup
- Push to the production branch → Cloudflare auto-builds and redeploys the docs.
- The Access gate stays in place across deploys.
- To add/remove people: Zero Trust → Access → Applications → (the app) → Policies.
Troubleshooting
| Symptom | Cause | Fix |
|---|---|---|
Build fails: vitepress: not found | Root directory not set | Set Root directory = backend/docs |
| Build fails: output dir empty | Wrong output path | Build output directory = .vitepress/dist (relative to root dir) |
| Build fails on Node version | Old Node on builder | Add env var NODE_VERSION=20 |
| Site loads but no login prompt | Access app domain mismatch | Ensure the Access Application domain exactly matches the live hostname |
| Anyone can view it | No Allow policy / app not covering domain | Confirm the Access application covers the exact hostname and has an Allow policy |
| Mermaid diagrams blank | Build used stale cache | Retry deployment / clear build cache in project settings |
Alternative: deploy without Git (direct upload)
If you prefer not to connect the repo, build locally and upload:
cd backend/docs
npm install
npm run docs:build
npx wrangler pages deploy .vitepress/dist --project-name oktivo-backend-docsThen apply the same Cloudflare Access steps (Part 2) to the resulting project.