canvas-website/CLOUDFLARE_PAGES_SETUP.md

1.2 KiB

Cloudflare Pages Configuration

Issue

Cloudflare Pages cannot use the same wrangler.toml file as Workers because:

  • wrangler.toml contains Worker-specific configuration (main, account_id, triggers, etc.)
  • Pages projects have different configuration requirements
  • Pages cannot have both main and pages_build_output_dir in the same file

Solution: Configure in Cloudflare Dashboard

Since wrangler.toml is for Workers only, configure Pages settings in the Cloudflare Dashboard:

Steps:

  1. Go to Cloudflare Dashboard
  2. Navigate to Pages → Your Project
  3. Go to SettingsBuilds & deployments
  4. Configure:
    • Build command: npm run build
    • Build output directory: dist
    • Root directory: / (or leave empty)
  5. Save settings

Alternative: Use Environment Variables

If you need to configure Pages via code, you can set environment variables in the Cloudflare Pages dashboard under SettingsEnvironment variables.

Worker Deployment

Workers are deployed separately using:

npm run deploy:worker

or

wrangler deploy

The wrangler.toml file is used only for Worker deployments, not Pages.