How sites are deployed to Cloudflare Pages with custom subdomains.
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 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
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).
Calls the Cloudflare API to check if a Pages project named <slug> already exists. Creates it if not.
Runs wrangler pages deploy <site_dir> --project-name <slug>. Wrangler uploads the site files and returns a deployment URL.
Calls the Cloudflare Pages API to attach the custom domain <slug>.demos.<domain> to the project.
Creates a CNAME record in the Cloudflare DNS zone pointing <slug>.demos to the Pages project's pages.dev URL.
The deploy script reads credentials from environment variables, never from files:
| Variable | Source |
|---|---|
CLOUDFLARE_API_TOKEN | Windows Registry via registry.py |
CLOUDFLARE_ACCOUNT_ID | Windows Registry |
CLOUDFLARE_ZONE_ID | Windows Registry |
CLOUDFLARE_DOMAIN | Windows 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.
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 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.
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.
| Limit | Free Tier |
|---|---|
| Projects | Unlimited |
| Deployments per month | 500 |
| Bandwidth | Unlimited |
| Custom domains per project | 100 |
| File size limit | 25 MB per file |
| Total files per deployment | 20,000 |
Normal agency usage (a few deployments per day) stays well within the free tier.