Cloudflare Pages Deployment with Google OAuth
This guide covers deploying the VitePress documentation site to Cloudflare Pages with Google OAuth authentication via Cloudflare Access.
NB: This is a work in progress and not yet complete, but the idea is cool.
Overview
- Local Development: No authentication (Docker only)
- Production: Cloudflare Pages with Cloudflare Access (Google OAuth)
- Access Control: Developer emails + founder admin domain
- Deployment: Automated via GitHub Actions
Prerequisites
- Cloudflare account
- Domain configured in Cloudflare
- Google Cloud project for OAuth credentials
- GitHub repository secrets configured
Step 1: Create Cloudflare Pages Project
Via Cloudflare Dashboard
- Go to Cloudflare Dashboard → Pages
- Click Create a project
- Select Direct Upload (we'll use GitHub Actions, not Git integration)
- Project name:
wedissimo-docs - Click Create project
Get Required Credentials
You'll need these for GitHub Actions:
Cloudflare Account ID:
- Dashboard → Pages → Account ID (in URL or sidebar)
- Format:
1234567890abcdef1234567890abcdef
Cloudflare API Token:
- Dashboard → My Profile → API Tokens → Create Token
- Use template: Edit Cloudflare Workers
- Or create custom token with permissions:
- Account → Cloudflare Pages → Edit
- Copy the token (shown only once)
Step 2: Configure GitHub Secrets
Add these secrets to your GitHub repository:
Settings → Secrets and variables → Actions → New repository secret
| Secret Name | Value | Where to Find |
|---|---|---|
CLOUDFLARE_API_TOKEN | Your API token | From Step 1 |
CLOUDFLARE_ACCOUNT_ID | Your account ID | From Step 1 |
Step 3: Set Up Google OAuth
Create OAuth Credentials
Go to Google Cloud Console
Select your project (or create new one)
Navigate to APIs & Services → Credentials
Click Create Credentials → OAuth 2.0 Client ID
Application type: Web application
Name:
Wedissimo Docs - Cloudflare AccessAuthorized redirect URIs:
https://<your-team-name>.cloudflareaccess.com/cdn-cgi/access/callbackReplace
<your-team-name>with your Cloudflare team name (found in Zero Trust dashboard)Click Create
Copy Client ID and Client Secret
Find Your Cloudflare Team Name
- Go to Cloudflare Zero Trust Dashboard
- Your team name is in the URL:
https://<team-name>.cloudflareaccess.com - Or check: Settings → General → Team domain
Step 4: Configure Cloudflare Access
Enable Cloudflare Access
- Go to Cloudflare Dashboard → Zero Trust
- Navigate to Access → Applications
- Click Add an application
- Select Self-hosted
Application Configuration
Application Details:
- Application name:
Wedissimo Developer Docs - Session Duration:
24 hours(or your preference) - Application domain:
- Subdomain:
docs(or your choice) - Domain:
wedissimo.com(or your domain) - Path: Leave empty (protect entire site)
- Subdomain:
Identity Providers:
- Click Add under Login Methods
- Select Google
- Enter your OAuth credentials:
- Client ID: (from Step 3)
- Client Secret: (from Step 3)
- Click Save
Access Policies
Create policies to allow access:
Policy 1: Developer Emails
- Policy name:
Developer Access - Action:
Allow - Rule type:
Include - Selector:
Emails - Value: Add individual developer emails:
developer1@example.com developer2@example.com
Policy 2: Founder Admin Domain
- Policy name:
Founder Admin Domain - Action:
Allow - Rule type:
Include - Selector:
Emails ending in - Value:
@founderandlightning.com(or your admin domain)
Example Combined Policy:
Include:
- Emails: dev1@example.com, dev2@example.com
- Emails ending in: @founderandlightning.comClick Save application
Step 5: Deploy via GitHub Actions
The deployment workflow is already configured in .github/workflows/deploy-docs.yml.
Trigger Deployment
Automatic:
- Push to
mainorstagingbranch - Changes in
docs/**directory
Manual:
- Go to Actions tab in GitHub
- Select Deploy VitePress Docs to Cloudflare Pages
- Click Run workflow
Workflow Overview
on:
push:
branches: [main, staging]
paths: ['docs/**']
workflow_dispatch:
jobs:
deploy:
- Checkout code
- Setup Node.js 20
- Install dependencies (docs/package.json)
- Build VitePress (npm run build)
- Deploy to Cloudflare PagesStep 6: Configure Custom Domain (Optional)
Add Custom Domain to Cloudflare Pages
- Cloudflare Dashboard → Pages → wedissimo-docs
- Go to Custom domains tab
- Click Set up a custom domain
- Enter:
docs.wedissimo.com - Cloudflare will automatically configure DNS
Update Cloudflare Access Application
- Go back to Zero Trust → Access → Applications
- Edit Wedissimo Developer Docs
- Update Application domain to match custom domain
- Save changes
Step 7: Verify Setup
Test Authentication Flow
- Visit your docs URL:
https://docs.wedissimo.com - You should see Cloudflare Access login page
- Click Sign in with Google
- Authenticate with allowed email
- You should be redirected to docs site
Test Access Control
Allowed users:
- ✅ Individual developer emails (from Policy 1)
- ✅ Any email ending in
@founderandlightning.com(from Policy 2)
Blocked users:
- ❌ Any other email addresses
Local Development (No Auth)
Local development runs without authentication:
# Start docs server (no auth required)
docker compose up wedissimo-docs
# Access at http://localhost:5174The Docker container runs VitePress directly without any authentication layer.
Troubleshooting
"Access Denied" for Valid Users
Check:
- Email is in allowed list or matches domain rule
- Google OAuth consent screen is configured
- User's email is verified in Google account
Redirect URI Mismatch
Error: redirect_uri_mismatch
Fix:
- Check Google OAuth credentials
- Ensure redirect URI matches exactly:
https://<team-name>.cloudflareaccess.com/cdn-cgi/access/callback - No trailing slashes or extra characters
Deployment Fails
Check:
- GitHub secrets are set correctly
- Cloudflare API token has correct permissions
- Build succeeds locally:
cd docs && npm run build
Session Expires Too Quickly
Fix:
- Go to Access application settings
- Increase Session Duration (e.g., 24 hours, 7 days)
- Save changes
Security Best Practices
Rotate Credentials Regularly
- Rotate Cloudflare API tokens every 90 days
- Rotate Google OAuth credentials annually
- Review access logs monthly
Monitor Access Logs
- Zero Trust → Logs → Access
- Review authentication attempts
- Set up alerts for suspicious activity
Principle of Least Privilege
- Only grant access to users who need it
- Use domain-based rules for teams
- Individual emails for contractors/external developers
Cost Considerations
Cloudflare Pages:
- Free tier: 500 builds/month, unlimited requests
- Paid tier: $20/month for more builds
Cloudflare Access:
- Free tier: Up to 50 users
- Paid tier: $3/user/month for 50+ users
Recommendation: Start with free tier, upgrade if needed.
Maintenance
Adding New Developers
Option 1: Individual Email
- Zero Trust → Access → Applications
- Edit Wedissimo Developer Docs
- Edit policy → Add email to list
Option 2: Use Domain
- If developer has
@founderandlightning.comemail, they're automatically allowed
Removing Access
- Edit access policy
- Remove email from list
- User's session will expire based on session duration
- Force immediate logout: Revoke user session in Access logs
Next Steps
- [ ] Set up Cloudflare Pages project
- [ ] Configure Google OAuth credentials
- [ ] Add GitHub secrets
- [ ] Configure Cloudflare Access policies
- [ ] Test deployment workflow
- [ ] Verify authentication works
- [ ] Add team members to access list