Module 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.

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: Request body

{ "domain_id": "uuid" }

Returns

200 - Success with domain host

Returns

400 - Missing domain_id

Returns

401 - Missing authorization header

Returns

404 - Domain not found or access denied

Returns

500 - Database deletion failure