Skip to content

digital-identity-platform-docs


digital-identity-platform-docs / supabase/functions/verify_custom_domain

supabase/functions/verify_custom_domain

Fileoverview

Verify Custom Domain Edge Function

Verifies DNS configuration for a custom domain and provisions the Caddy vhost if DNS verification succeeds.

Cloudflare Architecture Context

AttributeValue
Classification🔵 BACKEND-ONLY
PositionApp Backend (domain verification)
Receives Public TrafficNo (dashboard only)
Latency SensitiveNo
Safe to RetryYes (DNS check is idempotent)
Failure BehaviorUpdates domain status to 'error'

KV Sync: On successful verification, calls sync-edge-config to add the new host to:

  • EDGE_CONFIG (allowed_hosts array)
  • SITE_REGISTRY (per-host lookup)

Note: ROUTING_MAP is updated by infra-provisioner after Caddy setup.

Endpoint

POST /verify_custom_domain

Auth

Required - JWT verified by Supabase

Remarks

Verification process:

  1. Fetches domain record with container details
  2. Determines expected DNS value based on dns_method (A or CNAME)
  3. Queries Cloudflare DNS-over-HTTPS to verify record
  4. If DNS matches, calls Infrastructure Provisioner to add Caddy vhost
  5. Updates domain status to 'ready' or 'error'

DNS Methods:

  • a: Expects A record pointing to assigned edge server IP
  • cname: Expects CNAME record pointing to container's edge_hostname

Tables touched:

  • custom_domains (read/write)
  • sgtm_containers (read via join)

External services:

  • Cloudflare DNS-over-HTTPS (cloudflare-dns.com)
  • Infrastructure Provisioner (INFRA_PROVISIONER_URL) for Caddy setup

Example

json
{ "domain_id": "uuid" }

Interfaces

Released under proprietary license.