digital-identity-platform-docs
digital-identity-platform-docs / supabase/functions/delete_custom_domain
supabase/functions/delete_custom_domain
Fileoverview
Delete Custom Domain Edge Function
Handles the deletion of a custom domain from a container, including removal of the Caddy vhost configuration.
Cloudflare Architecture Context
| Attribute | Value |
|---|---|
| Classification | 🔵 BACKEND-ONLY |
| Position | App Backend (domain cleanup) |
| Receives Public Traffic | No (dashboard only) |
| Latency Sensitive | No |
| Safe to Retry | Partial (DB delete is not) |
| Failure Behavior | Best-effort Caddy cleanup, always deletes DB record |
KV Cleanup: Calls sync-edge-config to:
- Delete the specific host from SITE_REGISTRY
- Re-sync EDGE_CONFIG to update allowed_hosts array
Note: ROUTING_MAP cleanup is handled by infra-provisioner.
Endpoint
POST /delete_custom_domain
Auth
Required - JWT in Authorization header
Remarks
Deletion process:
- Verifies user has access to the domain via RLS
- Calls Infrastructure Provisioner to remove Caddy vhost
- Deletes the domain record from database
The Caddy removal is non-blocking - if it fails, the database record is still deleted to avoid orphaned records.
Tables touched:
- custom_domains (read/delete)
External services:
- Infrastructure Provisioner (INFRA_PROVISIONER_URL) for Caddy cleanup
Example
json
{ "domain_id": "uuid" }