Skip to main content
The Domain API handles connecting customer domains to our CloudFront proxy. This enables path-based routing where AI content lives at /ai/* while the rest of the site remains unchanged.

Services Used

Architecture

Path-Based Routing (No UA Cloaking)

We use path-based routing, NOT User-Agent based cloaking. This is safer and more transparent:

Why Path-Based?

  • No cloaking risk: Same content for bots and humans on same URLs
  • Transparent: Humans can access /ai/* pages too (they just won’t find them)
  • SEO safe: Clear separation between Shopify pages and AI pages
  • Canonical tags: /ai/* pages point canonical to Shopify URLs

Control File Takeover

We override these Shopify files at the edge:

Unified Sitemap Strategy

Our /sitemap.xml contains all URLs in a single file:
  1. Shopify URLs - Fetched during onboarding and stored in ai_sites.shopify_sitemap_urls
  2. AI pages - /ai/products/*, /ai/collections/*, /ai/<faq-slug>
  3. AI files - /llms.txt, /llms/*.txt
This ensures:
  • No confusion from multiple sitemaps
  • Shopify indexing is preserved
  • AI pages are discoverable

Connection Flow

The domain connection is a two-part process designed for zero downtime:

Part 1: SSL Certificate + Google TXT

  1. User clicks β€œStart Secure Connection”
  2. We request a Let’s Encrypt certificate via DNS-01 challenge
  3. We also request a Google verification token
  4. User adds BOTH TXT records via Entri (one-click DNS):
    • SSL validation TXT record
    • Google verification TXT record
  5. Let’s Encrypt validates and issues certificate
  6. Certificate is imported to ACM and attached to CloudFront

Part 2: Connect Domain + Verify Google

  1. SSL is ready on CloudFront
  2. User clicks β€œPoint Domain”
  3. User configures DNS via Entri (one-click):
    • CNAME www β†’ CloudFront distribution
    • A @ β†’ Our gateway IPs (for naked domain)
  4. Traffic now flows through our proxy (both www and naked domain)
  5. Background tasks trigger:
    • ACM-native certificate upgrade (auto-renewal)
    • Google verification polling (10s Γ— 12 = 2 min)
    • Once Google verified β†’ IndexNow + GSC sitemap submission
    • If Google fails β†’ IndexNow only (GSC skipped)
Both www and naked domain are configured together. Whether the user enters www.example.com or example.com as their business URL, Part 2 sets up DNS records for both to ensure the full domain works.

Status Flow

Endpoints

Setup CloudFront Proxy is now part of the Onboarding flow - it runs automatically during generate-all.

Why Let’s Encrypt + ACM?

We use a hybrid approach for SSL certificates: Initial: Let’s Encrypt
  • Works with ANY DNS provider
  • Bypasses CAA restrictions (Vercel/Netlify block ACM)
  • User adds one TXT record, done
After Connection: ACM-Native
  • Once www points to CloudFront, ACM can validate
  • Background upgrade happens automatically
  • ACM-native certs auto-renew forever
  • User never has to touch DNS again

Lambda@Edge Path-Based Routing

The Lambda@Edge function at origin-request routes based on URL path:

Updating Routing Rules

When routing rules need to change:
All customer distributions update automatically (~15 min for 1,000 customers). Zero downtime - old version runs until new one propagates.

Database Schema

The ai_sites table stores all proxy configuration: Users can disconnect their domain and reconnect later:

Disconnect Flow

  1. User clicks β€œDisconnect Domain”
  2. Frontend calls /disconnect-proxy β†’ gets restore DNS records
  3. Entri restores www CNAME to original
  4. Frontend calls /mark-disconnect-complete β†’ status becomes DISCONNECTED
  5. CloudFront + ACM stay intact (for fast relink)
  1. User clicks β€œReconnect”
  2. No CloudFront setup needed - distribution already exists
  3. Start certificate (if expired) or skip
  4. 2-step DNS flow: SSL CNAME β†’ www CNAME
  5. Status becomes DEPLOYED
This is much faster than initial setup because CloudFront and ACM are preserved.

Testing

The domain connection can be tested end-to-end: