Cloudflare DNS & Custom Domains
readyZero-downtime custom worker domains, automated apex/subdomain routing, SSL edge certificates, and DNS-level cutover mechanics.
Source reference: cli/internal/serverless/cloudflare_provider.go, shared/config/types.go
Custom Domains vs. Legacy Routes
In early versions of Cloudflare Workers, traffic was attached using route patterns (e.g. example.com/*). Modern Cloudflare Workers utilize Custom Domains:
- Automated DNS Record Provisioning: Cloudflare automatically configures internal
AAAA 100::routing records. - Automated SSL/TLS Management: Dedicated edge certificates are issued, validated, and auto-renewed by Cloudflare.
- Apex & Subdomain Parity: Seamless support for both root domains (
example.com) and subdomains (app.example.com). - No Route Pattern Conflicts: Custom domains operate at the DNS routing layer, bypassing path-based wildcard routing conflicts.
NextDeploy manages Custom Domains declaratively inside nextdeploy.yml.
Configuration in nextdeploy.yml
version: "1.0"
target_type: serverless
app:
name: my-edge-app
domain: app.example.com
environment: production
serverless:
provider: cloudflare
cloudflare:
compatibility_date: "2026-05-01"
compatibility_flags:
- nodejs_compat
custom_domains:
- hostname: app.example.com
zone_name: example.com
- hostname: example.com
zone_name: example.com
resources:
dns:
- zone: example.com
name: "@"
type: MX
content: mail.example.com
priority: 10
ttl: 300
NextDeploy reconciles A, AAAA, CNAME, TXT, MX, NS, CAA, and SRV records under resources.dns, and respects cache_purge.strategy (everything, hosts, prefixes, tags, or none).
Zero-Downtime Deployment Lifecycle
When executing nextdeploy ship:
The 5-Step Cutover Protocol:
- Permission Validation: NextDeploy verifies that your API token has
Zone: Read,DNS: Edit, andWorkers Scripts: Editpermissions. - Asset Pre-Upload: Static assets are uploaded directly to Cloudflare R2 so edge caching is immediately primed.
- Worker Script Upload: The compiled Next.js worker script bundle is uploaded and validated by Cloudflare's runtime validator.
- Domain Attachment: NextDeploy binds the custom domains to the newly uploaded Worker version.
- Global Propagation & Smoke Verification: Edge nodes route incoming HTTPS traffic to the new script within 3 to 5 seconds. NextDeploy performs automated
SmokeVerifyprobes before signaling success.
Handling Apex Domains & CNAME Flattening
When routing apex domains (example.com) on Cloudflare:
- Cloudflare DNS implements CNAME Flattening at the root zone automatically.
- No third-party DNS workarounds or ALIAS record hacks are necessary.
- If your root domain's DNS is hosted outside Cloudflare, you can delegate only a subdomain (
app.example.com) to Cloudflare Workers Custom Domains using standardCNAMErecords.
Verifying Propagation
# Verify worker custom domain resolution
dig app.example.com AAAA +short
# Test live response headers
curl -I https://app.example.com
Look for the cf-ray header and server: cloudflare, confirming that traffic is routed through Cloudflare's global edge network.