Deploy your API documentation to Cloudflare Pages with password protection.
- GitHub account
- Cloudflare account (free)
- Domain with nameservers pointed to Cloudflare
# Initialize git repo
cd wallet-api-docs
git init
git add .
git commit -m "Initial commit"
# Create repo on GitHub, then push
git remote add origin git@github.com:YOUR_ORG/wallet-api-docs.git
git branch -M main
git push -u origin main- Go to Cloudflare Dashboard
- Select your account
- Go to Workers & Pages → Create application → Pages
- Click Connect to Git
- Select your GitHub repository
- Configure build settings:
| Setting | Value |
|---|---|
| Framework preset | Astro |
| Build command | npm run build |
| Build output directory | dist |
- Click Save and Deploy
- After deployment, go to your Pages project
- Click Custom domains tab
- Click Set up a custom domain
- Enter your domain (e.g.,
docs.yourcasino.com) - Cloudflare will automatically configure DNS
- Go to Zero Trust in Cloudflare dashboard
- Navigate to Access → Applications
- Click Add an application → Self-hosted
- Configure:
| Field | Value |
|---|---|
| Application name | API Docs |
| Subdomain | docs |
| Domain | yourcasino.com |
- Add policy:
| Field | Value |
|---|---|
| Policy name | Team Access |
| Action | Allow |
| Include | Emails ending in @yourcompany.com |
- Save
Now users must verify their email to access the docs.
- In Zero Trust → Access → Applications
- Create application as above
- Add policy with One-time PIN:
| Field | Value |
|---|---|
| Policy name | PIN Access |
| Action | Allow |
| Include | Everyone |
| Require | One-time PIN |
- Set allowed emails or "Any email" for PIN delivery
- Visit your custom domain (e.g.,
https://docs.yourcasino.com) - You should see the Cloudflare Access login page
- Enter your email → receive code → access granted
- Documentation site loads
# Install dependencies
npm install
# Start dev server
npm run dev
# Build for production
npm run build
# Preview production build
npm run preview- Edit markdown files in
src/content/docs/ - Commit and push to GitHub
- Cloudflare Pages automatically rebuilds and deploys
git add .
git commit -m "Update API documentation"
git pushDeployment takes ~1-2 minutes.
wallet-api-docs/
├── astro.config.mjs # Astro + Starlight config
├── package.json # Dependencies
├── wrangler.toml # Cloudflare config
├── public/
│ └── favicon.svg
├── src/
│ ├── assets/
│ │ └── logo.svg
│ ├── styles/
│ │ └── custom.css
│ └── content/
│ └── docs/
│ ├── index.mdx # Home page
│ ├── authentication.mdx # Auth docs
│ ├── chains.mdx # Supported chains
│ ├── wallets/ # Wallet endpoints
│ ├── addresses/ # Address endpoints
│ ├── payments/ # Payment endpoints
│ ├── webhooks/ # Webhook docs
│ ├── errors.mdx # Error codes
│ ├── rate-limits.mdx # Rate limits
│ └── sdks.mdx # SDK examples
Check that all dependencies are installed:
rm -rf node_modules
npm install
npm run build- Verify the application domain matches exactly
- Check that the policy is set to "Allow" not "Block"
- Ensure emails are in the correct format
- Check DNS is configured (CNAME to pages.dev URL)
- Wait up to 24 hours for DNS propagation
- Verify SSL/TLS is set to "Full" in Cloudflare
- Access protection enabled
- Only team emails allowed
- robots.txt blocks indexing (already configured)
- No real API keys in examples
- HTTPS enforced (automatic)