Skip to content

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

AttributeValue
Classification🔵 BACKEND-ONLY
PositionApp Backend (domain cleanup)
Receives Public TrafficNo (dashboard only)
Latency SensitiveNo
Safe to RetryPartial (DB delete is not)
Failure BehaviorBest-effort Caddy cleanup, always deletes DB record

KV Cleanup: Calls sync-edge-config to:

  1. Delete the specific host from SITE_REGISTRY
  2. 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:

  1. Verifies user has access to the domain via RLS
  2. Calls Infrastructure Provisioner to remove Caddy vhost
  3. 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" }

Interfaces

Released under proprietary license.