landing_page.github.io

Cloudflare Workers Deployment Guide

This guide explains how to deploy this Next.js landing page to Cloudflare Workers/Pages.

Prerequisites

  1. A Cloudflare account (sign up at https://dash.cloudflare.com/sign-up)
  2. Node.js 18 or higher installed
  3. pnpm package manager installed

Local Development

cd landingPage
pnpm install
pnpm dev

Building for Cloudflare

cd landingPage
pnpm run pages:build

This will create a .vercel/output/static directory with the built application.

Local Preview with Cloudflare Workers

cd landingPage
pnpm run preview

This will start a local Cloudflare Pages development server.

Manual Deployment

Option 1: Using Wrangler CLI

  1. Install wrangler globally (if not already installed):
    npm install -g wrangler
    
  2. Authenticate with Cloudflare:
    wrangler login
    
  3. Deploy to Cloudflare Pages:
    cd landingPage
    pnpm run pages:deploy
    

Option 2: Using Cloudflare Dashboard

  1. Build the project:
    cd landingPage
    pnpm run pages:build
    
  2. Go to Cloudflare Dashboard → Pages
  3. Create a new project
  4. Upload the .vercel/output/static folder

Automated Deployment (GitHub Actions)

The repository includes a GitHub Actions workflow that automatically deploys to Cloudflare Pages on every push to the main branch.

Required GitHub Secrets

Add these secrets to your GitHub repository (Settings → Secrets and variables → Actions):

  1. CLOUDFLARE_API_TOKEN: Your Cloudflare API token
    • Create at: https://dash.cloudflare.com/profile/api-tokens
    • Use the “Edit Cloudflare Workers” template or create a custom token with “Cloudflare Pages:Edit” permissions
  2. CLOUDFLARE_ACCOUNT_ID: Your Cloudflare account ID
    • Find at: https://dash.cloudflare.com/ (in the URL or on the right sidebar)
  3. NEXT_PUBLIC_SUPABASE_URL: Your Supabase project URL (if using Supabase)

  4. NEXT_PUBLIC_SUPABASE_ANON_KEY: Your Supabase anonymous key (if using Supabase)

Configuration

wrangler.toml

The wrangler.toml file in the landingPage directory contains the Cloudflare Workers configuration. Update the following:

Environment Variables

If your application uses environment variables, add them to:

Important Notes

  1. Static Export: This configuration uses Next.js with Cloudflare adapter to generate edge-compatible output
  2. Image Optimization: Images are set to unoptimized: true for Cloudflare compatibility
  3. Supabase: The app uses Supabase for form submissions - make sure to configure the environment variables
  4. Custom Domain: Configure your custom domain in Cloudflare Pages dashboard

Troubleshooting

Build Fails

Deployment Fails

Runtime Errors

Additional Resources