Deployment Infrastructure

How sites are deployed to Cloudflare Pages with custom subdomains.

Overview

Every demo and final site is deployed to Cloudflare Pages — a global CDN hosting platform with a generous free tier and instant deploys. Each site gets its own Pages project and a custom subdomain attached via a CNAME DNS record.

Demo Subdomain Pattern

Demo sites follow this URL pattern:

https://<slug>.demos.<your-domain>

For example, if your domain is hippopotamoose.net and the business slug is smithplumbing, the demo URL is:

https://smithplumbing.demos.hippopotamoose.net

The deploy-demo.ps1 Script

Location: E:\Sites\deploy-demo.ps1

This script is called by DeployWorker with the -SiteName <slug> parameter. It reads all credentials from environment variables set by the app at runtime (never from files on disk).

What the Script Does

Check for existing Pages project

Calls the Cloudflare API to check if a Pages project named <slug> already exists. Creates it if not.

Deploy with Wrangler

Runs wrangler pages deploy <site_dir> --project-name <slug>. Wrangler uploads the site files and returns a deployment URL.

Attach custom domain

Calls the Cloudflare Pages API to attach the custom domain <slug>.demos.<domain> to the project.

Create DNS record

Creates a CNAME record in the Cloudflare DNS zone pointing <slug>.demos to the Pages project's pages.dev URL.

Environment Variables

The deploy script reads credentials from environment variables, never from files:

VariableSource
CLOUDFLARE_API_TOKENWindows Registry via registry.py
CLOUDFLARE_ACCOUNT_IDWindows Registry
CLOUDFLARE_ZONE_IDWindows Registry
CLOUDFLARE_DOMAINWindows Registry

DeployWorker passes these to the PowerShell process via env= on the subprocess call.

⚠️

Never write these credentials into the deploy script itself or any file on disk. The script reads them from the environment automatically.

Markdown Viewer Publishing

When the Host Demo step runs, the app also checks for .md files in the site's edited_sites/<slug>/ folder (typically DESIGN_NOTES.md written by the AI during Demo). If any are found, they are published to a markdown viewer subdomain using deploy-viewer.ps1 -Type markdown.

The viewer is accessible at:

https://<slug>-notes.demos.<your-domain>

This lets you share the AI's design rationale with clients alongside the live demo.

Wrangler Authentication

Wrangler authenticates using the CLOUDFLARE_API_TOKEN environment variable. The token must have these permissions:

Create the token in Cloudflare Dashboard → My Profile → API Tokens → Create Token → Custom Token.

DNS Propagation

After deployment, the custom subdomain may take 1–5 minutes to become accessible globally due to DNS propagation. The app marks the step complete as soon as the deploy script exits successfully — it does not wait for DNS propagation.

Cloudflare Pages Free Tier Limits

LimitFree Tier
ProjectsUnlimited
Deployments per month500
BandwidthUnlimited
Custom domains per project100
File size limit25 MB per file
Total files per deployment20,000

Normal agency usage (a few deployments per day) stays well within the free tier.