Skip to main content

Cloudflare Pages Deployment

This document provides detailed instructions for deploying the L2 Support Tools & Documentation site to Cloudflare Pages using GitHub integration.

Overview

Cloudflare Pages is a JAMstack platform for frontend developers to collaborate and deploy websites. It offers:

  • Continuous deployment from Git
  • Global CDN distribution
  • Free SSL certificates
  • Custom domains
  • Access control via Cloudflare Access (ZeroTrust)

Prerequisites

  • A Cloudflare account
  • Admin access to the GitHub repository
  • Node.js 18.x or higher (specified in the Cloudflare build environment)

Deployment Steps

1. Connect GitHub Repository to Cloudflare Pages

  1. Log in to the Cloudflare Dashboard
  2. Navigate to Pages in the sidebar
  3. Click Create a project
  4. Select Connect to Git
  5. Authenticate with GitHub if prompted
  6. Select the L2Toolbox repository from the list

2. Configure Build Settings

Configure the following build settings:

SettingValue
Project namel2-support-tools (or your preferred name)
Production branchmain (or your preferred branch)
Build commandnpm install && npm run build
Build output directorybuild
Root directory/ (leave as default)

3. Environment Variables (Optional)

Add the following environment variables if needed:

VariableValueDescription
NODE_VERSION18Ensures Node.js 18.x is used during build

4. Advanced Settings (Optional)

  • Preview Deployments: Enable to create preview deployments for pull requests
  • Production Deployments: Configure automatic deployments when changes are pushed to the main branch
  • Build Cache: Enable to speed up builds by caching dependencies

5. Deploy

Click Save and Deploy to start the initial build and deployment process.

Post-Deployment Configuration

Custom Domain (Optional)

  1. In the Cloudflare Pages project, go to Custom domains
  2. Click Set up a custom domain
  3. Enter your domain name and follow the instructions

Access Control with Cloudflare Access

To implement ZeroTrust access control:

  1. Navigate to Access in the Cloudflare dashboard
  2. Create a new application
  3. Set the application domain to your Cloudflare Pages URL
  4. Configure access policies to restrict access to authorized users:
    • Email domains
    • Individual email addresses
    • Identity provider groups
    • etc.

Automatic Deployments

Once configured, Cloudflare Pages will automatically:

  1. Detect changes pushed to the configured branch
  2. Trigger a new build
  3. Deploy the updated site to the global CDN

No manual deployment steps are required after the initial setup.

Troubleshooting

Build Failures

If a build fails:

  1. Check the build logs in the Cloudflare Pages dashboard
  2. Verify that the build command and output directory are correct
  3. Ensure all dependencies are properly specified in package.json
  4. Check for any environment-specific code that might not work in the Cloudflare build environment

Access Issues

If users cannot access the site:

  1. Verify Cloudflare Access policies are correctly configured
  2. Check that users are authenticating with the correct credentials
  3. Review Access logs for failed authentication attempts

Additional Resources