Purpose: Enable programmatic DNS management via Cloudflare API
Timeline: 30 minutes of work + 24-48 hours DNS propagation
Status: Production-ready

Prerequisites

  • Access to GoDaddy account (freebeer.ai registrar)
  • Access to SiteGround account (current DNS host)
  • Email address for Cloudflare account
  • Test domain for practice (optional but recommended)

Part 1: Practice with Test Domain (Optional)

Why Practice First?

  • Gain confidence with the process
  • Understand what happens during migration
  • No risk to production freebeer.ai domain
  • Can test DNS changes without affecting live sites
Recommended: If you have a test domain, run through the complete process first before proceeding with freebeer.ai migration.

Part 2: Cloudflare Account Setup

Step 1: Create Cloudflare Account

  1. Go to: https://dash.cloudflare.com/sign-up
  2. Enter email address
  3. Create password
  4. Verify email (check inbox for verification link)
  5. Log in to Cloudflare dashboard

Checkpoint: You should see empty Cloudflare dashboard with "Add a Site" button

Step 2: Add freebeer.ai Domain

  1. Click "Add a Site" button
  2. Enter domain: freebeer.ai
  3. Click "Add site"
  4. Choose plan: Free (scroll down, it's at the bottom)
  5. Click "Continue"

Cloudflare will now scan your existing DNS records from SiteGround (~60 seconds).

Step 3: Review DNS Records

Cloudflare will display all DNS records it found. IMPORTANT: Review carefully!

Expected records for freebeer.ai:

Type: A
Name: @ (or freebeer.ai)
Content: [SiteGround IP address]
TTL: Auto

Type: CNAME
Name: www
Content: freebeer.ai
TTL: Auto

Type: CNAME
Name: dev
Content: cname.vercel-dns.com
TTL: Auto

Type: CNAME
Name: staging
Content: cname.vercel-dns.com
TTL: Auto

Type: CNAME
Name: app
Content: cname.vercel-dns.com
TTL: Auto

... (any other records you have)

What to do:

  1. Review each record - make sure nothing is missing
  2. Check the three Vercel CNAMEs are present (dev, staging, app)
  3. If any records are missing, note them down
  4. Click "Continue"
If something looks wrong: Don't panic! You can add missing records manually later in Cloudflare dashboard.

Step 4: Get Nameserver Information

Cloudflare will show you two nameservers to use. They'll look like:

bella.ns.cloudflare.com
kurt.ns.cloudflare.com
IMPORTANT: Copy these down! You'll need them for the next step.
Don't click "Done" yet - keep this page open in a browser tab.

Part 3: Update Nameservers at GoDaddy

Step 5: Log into GoDaddy

  1. Go to: https://www.godaddy.com
  2. Log in to your account
  3. Click "My Products"
  4. Find freebeer.ai in your domain list
  5. Click "DNS" or "Manage DNS"

Step 6: Change Nameservers

  1. Scroll down to "Nameservers" section
  2. Click "Change" or "Manage"
  3. Select "Custom" or "Enter my own nameservers"

Current nameservers (SiteGround - you're replacing these):

ns1.siteground.com
ns2.siteground.com
(or similar)

New nameservers (Cloudflare - from Step 4):

bella.ns.cloudflare.com
kurt.ns.cloudflare.com
(use the exact names Cloudflare gave you)
  1. Remove old SiteGround nameservers
  2. Add new Cloudflare nameservers (both of them)
  3. Click "Save"
GoDaddy will warn you: "Changing nameservers may affect your website, email, etc."
This is normal. Click "Continue" or "Yes".

Step 7: Confirm in Cloudflare

  1. Go back to Cloudflare tab
  2. Click "Done, check nameservers"

Expected result: One of two things will happen:

Option A: "Great! We detected your nameservers"

  • Cloudflare immediately sees the change
  • You're done! Skip to Step 8

Option B: "We haven't detected your nameservers yet"

  • Normal! DNS propagation takes time
  • Cloudflare will send you email when detected
  • Continue to Step 8

Part 4: Wait for DNS Propagation

Step 8: Monitoring Propagation

What's happening:

  • GoDaddy has updated nameservers
  • DNS servers worldwide are caching old nameservers
  • Takes 24-48 hours for all servers to see new nameservers

How to Check Progress

Method 1: Cloudflare Dashboard

  • Log into Cloudflare
  • Check freebeer.ai status
  • Will show "Active" when fully migrated

Method 2: Command Line

# Check what nameservers are being returned
dig NS freebeer.ai

# Should eventually show:
# freebeer.ai.  86400  IN  NS  bella.ns.cloudflare.com.
# freebeer.ai.  86400  IN  NS  kurt.ns.cloudflare.com.

Method 3: Online Tool

Timeline:

Time Status
0-6 hours Partial propagation
6-24 hours Most servers updated
24-48 hours Full global propagation

Step 9: Verify Existing Sites Still Work

After propagation completes (Cloudflare shows "Active"):

Test each of your existing sites:

# Test main domain
curl -I https://freebeer.ai
# Should return: 200 OK

# Test PAI Dashboard environments
curl -I https://dev.freebeer.ai
curl -I https://staging.freebeer.ai
curl -I https://app.freebeer.ai
# All should return: 200 OK

In browser: Visit each URL and confirm sites load normally.

If sites don't load:
  1. Clear browser cache (Cmd+Shift+R on Mac)
  2. Wait another 12 hours for DNS to fully propagate
  3. Check Cloudflare DNS records match SiteGround records

Part 5: Cloudflare Configuration

Step 10: SSL/TLS Settings

IMPORTANT: Configure SSL settings correctly
  1. Go to Cloudflare dashboard → freebeer.ai
  2. Click "SSL/TLS" in left sidebar
  3. Under "Overview", select: "Full (strict)"

Why: Your sites already have SSL from Vercel. This setting ensures Cloudflare's SSL works with Vercel's SSL.

Step 11: Enable Auto-Minify (Optional)

For better performance:

  1. Go to: SpeedOptimization
  2. Enable Auto Minify for:
    • JavaScript
    • CSS
    • HTML
  3. Save

Step 12: Security Settings (Optional)

Default settings are fine, but you can enhance:

  1. Go to: SecuritySettings
  2. Security Level: Medium (default)
  3. Challenge Passage: 30 minutes (default)
  4. Browser Integrity Check: ON (recommended)

Part 6: Get Cloudflare API Token

Step 13: Create API Token for Automation

This enables the automation script to manage DNS programmatically

  1. Go to: Cloudflare Dashboard → Profile (top right)
  2. Click "API Tokens"
  3. Click "Create Token"
  4. Find template: "Edit zone DNS"
  5. Click "Use template"

Configure token:

  • Permissions: Zone / DNS / Edit ✓
  • Zone Resources:
    • Include / Specific zone / freebeer.ai
  • IP Address Filtering: (leave blank for now)
  1. Click "Continue to summary"
  2. Review permissions
  3. Click "Create Token"
IMPORTANT: Copy the token NOW
Cloudflare API Token: [long string starting with underscore]

Save this token: You'll add it to your environment variables:

# Add to ~/.zshrc
export CLOUDFLARE_API_TOKEN="your_token_here"

Also get your Zone ID:

  1. Go back to Cloudflare dashboard
  2. Click on freebeer.ai domain
  3. Scroll down on Overview page
  4. Find "Zone ID" on the right side
  5. Copy it
# Add to ~/.zshrc
export CLOUDFLARE_ZONE_ID="your_zone_id_here"

Part 7: Test API Access

Step 14: Verify API Token Works

# Source your .zshrc to load new variables
source ~/.zshrc

# Test API access
curl -X GET "https://api.cloudflare.com/client/v4/zones/$CLOUDFLARE_ZONE_ID/dns_records" \
  -H "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
  -H "Content-Type: application/json"

Expected result: JSON response listing all your DNS records

If you get an error: Double-check token and zone ID are correct

Part 8: Add Client Subdomain Pattern (Test)

Step 15: Test Adding a Client Subdomain via API

Let's test the automation by adding a test client subdomain:

# Add a test dev subdomain
curl -X POST "https://api.cloudflare.com/client/v4/zones/$CLOUDFLARE_ZONE_ID/dns_records" \
  -H "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "type": "CNAME",
    "name": "test-client.dev",
    "content": "cname.vercel-dns.com",
    "ttl": 300,
    "proxied": false
  }'

Expected result: JSON response with "success": true

Verify in Cloudflare dashboard:

  1. Go to: DNS → Records
  2. Look for: test-client.dev CNAME record
  3. Should point to: cname.vercel-dns.com

Test it works:

dig test-client.dev.freebeer.ai

# Should show:
# test-client.dev.freebeer.ai. 300 IN CNAME cname.vercel-dns.com.
Success! Your API automation is working!

Clean up the test record (via Cloudflare dashboard or API):

# List records to find the ID
curl -X GET "https://api.cloudflare.com/client/v4/zones/$CLOUDFLARE_ZONE_ID/dns_records?name=test-client.dev.freebeer.ai" \
  -H "Authorization: Bearer $CLOUDFLARE_API_TOKEN"

# Delete using the record ID from response
curl -X DELETE "https://api.cloudflare.com/client/v4/zones/$CLOUDFLARE_ZONE_ID/dns_records/[RECORD_ID]" \
  -H "Authorization: Bearer $CLOUDFLARE_API_TOKEN"

Completion Checklist

  • Cloudflare account created
  • freebeer.ai added to Cloudflare
  • All DNS records reviewed and confirmed
  • Nameservers updated at GoDaddy
  • DNS propagation complete (24-48 hours)
  • All existing sites verified working
  • SSL/TLS set to "Full (strict)"
  • API token created and saved
  • Zone ID saved
  • Environment variables added to ~/.zshrc
  • API access tested successfully
  • Test subdomain created and verified via API

Troubleshooting

"Sites not loading after migration"

Check:

  1. DNS propagation complete? (use whatsmydns.net)
  2. SSL mode set to "Full (strict)"? (Cloudflare dashboard)
  3. All DNS records copied correctly? (compare SiteGround vs Cloudflare)

Fix: Wait longer (up to 48 hours) or clear browser cache

"API token not working"

Check:

  1. Token copied correctly? (no extra spaces)
  2. Zone ID correct?
  3. Token has "Edit zone DNS" permission?

Fix: Create new token, ensure permissions are correct

"Cloudflare shows nameservers not detected"

Check:

  1. Nameservers updated at GoDaddy? (check GoDaddy dashboard)
  2. Correct Cloudflare nameservers used? (check Cloudflare setup page)

Fix: Wait 24-48 hours, Cloudflare checks periodically

Next Steps

Once Cloudflare migration is complete:

  1. ✅ Phase 1 complete!
  2. → Proceed to Phase 2: Create client template repository
  3. → Build automation script that uses Cloudflare API