Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

docs: update custom domain docs for verification process (#29344)

Crispyc69ac64ad5a6
diff --git a/apps/docs/content/guides/platform/custom-domains.mdx b/apps/docs/content/guides/platform/custom-domains.mdx
index 6ba6190c154..03a998fb62d 100644
--- a/apps/docs/content/guides/platform/custom-domains.mdx
+++ b/apps/docs/content/guides/platform/custom-domains.mdx
@@ -68,16 +68,15 @@ In the CLI, run [`domains create`](/docs/reference/cli/supabase-domains-create)
supabase domains create --project-ref abcdefghijklmnopqrst --custom-hostname api.example.com
```
-Two TXT records are returned. For example:
+A single TXT records is returned. For example:
```text
[...]
Required outstanding validation records:
- _cf-custom-hostname.api.example.com TXT -> 46BBC14D-D50A-409C-8DB5-F862CF5BA660
- api.example.com TXT -> ca3-F1HvR9i938OgVwpCFwi1jTsbhe1hvT0Ic3efPY3Q
+ _acme-challenge.api.example.com. TXT -> ca3-F1HvR9i938OgVwpCFwi1jTsbhe1hvT0Ic3efPY3Q
```
-Add the records to your domains' DNS settings. Make sure to trim surrounding whitespace. Use a low TTL value so you can quickly change the records if you make a mistake.
+Add the record to your domains' DNS settings. Make sure to trim surrounding whitespace. Use a low TTL value so you can quickly change the records if you make a mistake.
Some DNS registrars automatically append your domain name to the DNS entries being created. As such, creating a DNS record for `api.example.com` might instead create a record for `api.example.com.example.com`. In such cases, please remove the domain name from the records you're creating; as an example, you would create a TXT record for `api`, instead of `api.example.com`.
@@ -86,8 +85,7 @@ Some DNS registrars automatically append your domain name to the DNS entries bei
Make sure you've configured all required DNS settings:
- CNAME for your custom domain pointing to the Supabase project domain.
-- TXT record for `_cf-custom-hostname.<domain>`.
-- TXT record for `<domain>`.
+- TXT record for `_acme-challenge.<your-custom-domain>`.
Use the [`domains reverify`](/docs/reference/cli/supabase-domains-reverify) command to begin the verification process of your domain. You may need to run this command a few times because DNS records take a while to propagate.
diff --git a/apps/studio/components/interfaces/Settings/General/CustomDomainConfig/CustomDomainActivate.tsx b/apps/studio/components/interfaces/Settings/General/CustomDomainConfig/CustomDomainActivate.tsx
index 055b40e85f0..eee3f944a8b 100644
--- a/apps/studio/components/interfaces/Settings/General/CustomDomainConfig/CustomDomainActivate.tsx
+++ b/apps/studio/components/interfaces/Settings/General/CustomDomainConfig/CustomDomainActivate.tsx
@@ -66,19 +66,19 @@ const CustomDomainActivate = ({ projectRef, customDomain }: CustomDomainActivate
<Alert_Shadcn_>
<AlertCircle className="text-foreground-light" strokeWidth={1.5} />
<AlertTitle_Shadcn_>
- Remember to restore the original CNAME record from the first step before activating
+ Remember to retain your CNAME record for service continuity after activation
</AlertTitle_Shadcn_>
<AlertDescription_Shadcn_>
<p className="col-span-12 text-sm lg:col-span-7 leading-6">
- Set up a CNAME record for <code className="text-xs">{customDomain.hostname}</code>
- , resolving to{' '}
+ Your custom domain CNAME record for{' '}
+ <code className="text-xs">{customDomain.hostname}</code>
+ should resolve to{' '}
{endpoint ? (
<code className="text-xs">{endpoint}</code>
) : (
"your project's API URL"
)}
- , with as low a TTL as possible. If you're using Cloudflare as your DNS provider,
- disable the proxy option.
+ . If you're using Cloudflare as your DNS provider, disable the proxy option.
</p>
</AlertDescription_Shadcn_>
</Alert_Shadcn_>
diff --git a/apps/studio/components/interfaces/Settings/General/CustomDomainConfig/CustomDomainConfig.tsx b/apps/studio/components/interfaces/Settings/General/CustomDomainConfig/CustomDomainConfig.tsx
index 08f7e363865..bcde78bace3 100644
--- a/apps/studio/components/interfaces/Settings/General/CustomDomainConfig/CustomDomainConfig.tsx
+++ b/apps/studio/components/interfaces/Settings/General/CustomDomainConfig/CustomDomainConfig.tsx
@@ -34,7 +34,19 @@ const CustomDomainConfig = () => {
isError,
isSuccess,
data,
- } = useCustomDomainsQuery({ projectRef: ref })
+ } = useCustomDomainsQuery(
+ { projectRef: ref },
+ {
+ refetchInterval(data) {
+ // while setting up the ssl certificate, we want to poll every 5 seconds
+ if (data?.customDomain?.ssl.status) {
+ return 5000
+ }
+
+ return false
+ },
+ }
+ )
const isLoading = isSettingsLoading || isCustomDomainsLoading
diff --git a/apps/studio/components/interfaces/Settings/General/CustomDomainConfig/CustomDomainVerify.tsx b/apps/studio/components/interfaces/Settings/General/CustomDomainConfig/CustomDomainVerify.tsx
index f0c1d2133bc..244664f456d 100644
--- a/apps/studio/components/interfaces/Settings/General/CustomDomainConfig/CustomDomainVerify.tsx
+++ b/apps/studio/components/interfaces/Settings/General/CustomDomainConfig/CustomDomainVerify.tsx
@@ -1,3 +1,4 @@
+import { AlertCircle, ExternalLink, HelpCircle, RefreshCw } from 'lucide-react'
import Link from 'next/link'
import { useState } from 'react'
@@ -6,6 +7,7 @@ import type { ProjectApiResponse } from 'data/config/project-api-query'
import { useCustomDomainDeleteMutation } from 'data/custom-domains/custom-domains-delete-mutation'
import type { CustomDomainResponse } from 'data/custom-domains/custom-domains-query'
import { useCustomDomainReverifyMutation } from 'data/custom-domains/custom-domains-reverify-mutation'
+import { useInterval } from 'hooks/misc/useInterval'
import {
AlertDescription_Shadcn_,
AlertTitle_Shadcn_,
@@ -14,7 +16,7 @@ import {
WarningIcon,
} from 'ui'
import DNSRecord from './DNSRecord'
-import { AlertCircle, HelpCircle, ExternalLink, RefreshCw } from 'lucide-react'
+import { DNSTableHeaders } from './DNSTableHeaders'
export type CustomDomainVerifyProps = {
projectRef?: string
@@ -31,18 +33,26 @@ const CustomDomainVerify = ({ projectRef, customDomain, settings }: CustomDomain
if (res.status === '2_initiated') setIsNotVerifiedYet(true)
},
})
+
const { mutate: deleteCustomDomain, isLoading: isDeleting } = useCustomDomainDeleteMutation()
const hasCAAErrors = customDomain.ssl.validation_errors?.reduce(
(acc, error) => acc || error.message.includes('caa_error'),
false
)
+ const isValidating = (customDomain.ssl.txt_name ?? '') === ''
const onReverifyCustomDomain = () => {
if (!projectRef) return console.error('Project ref is required')
reverifyCustomDomain({ projectRef })
}
+ useInterval(
+ onReverifyCustomDomain,
+ // Poll every 5 seconds if the SSL certificate is being deployed
+ customDomain.ssl.status !== undefined && customDomain.ssl.txt_name === undefined ? 5000 : false
+ )
+
const onCancelCustomDomain = async () => {
if (!projectRef) return console.error('Project ref is required')
deleteCustomDomain({ projectRef })
@@ -63,28 +73,32 @@ const CustomDomainVerify = ({ projectRef, customDomain, settings }: CustomDomain
<p className="text-sm text-foreground-light">
Records which have been successfully verified will be removed from this list below.
</p>
- <div className="mt-4 mb-2">
- <Alert_Shadcn_ variant="default">
- {isNotVerifiedYet ? (
- <AlertCircle className="text-foreground-light" strokeWidth={1.5} />
- ) : (
- <HelpCircle className="text-foreground-light" strokeWidth={1.5} />
- )}
- <AlertTitle_Shadcn_>
- {isNotVerifiedYet
- ? 'Unable to verify records from DNS provider yet.'
- : 'Please note that it may take up to 24 hours for the DNS records to propagate.'}
- </AlertTitle_Shadcn_>
- <AlertDescription_Shadcn_>
+ {!isValidating && (
+ <div className="mt-4 mb-2">
+ <Alert_Shadcn_ variant="default">
{isNotVerifiedYet ? (
- <div className="mt-2">
- <p>
- Please check again soon. Note that it may take up to 24 hours for changes in
- DNS records to propagate.
- </p>
+ <AlertCircle className="text-foreground-light" strokeWidth={1.5} />
+ ) : (
+ <HelpCircle className="text-foreground-light" strokeWidth={1.5} />
+ )}
+ <AlertTitle_Shadcn_>
+ {isNotVerifiedYet
+ ? 'Unable to verify records from DNS provider yet.'
+ : 'Please note that it may take up to 24 hours for the DNS records to propagate.'}
+ </AlertTitle_Shadcn_>
+ <AlertDescription_Shadcn_>
+ <div>
+ {isNotVerifiedYet && (
+ <p>
+ Please check again soon. Note that it may take up to 24 hours for changes in
+ DNS records to propagate.
+ </p>
+ )}
<p>
You may also visit{' '}
<Link
+ target="_blank"
+ rel="noreferrer"
href={`https://whatsmydns.net/#TXT/${customDomain.hostname}`}
className="text-brand"
>
@@ -92,27 +106,18 @@ const CustomDomainVerify = ({ projectRef, customDomain, settings }: CustomDomain
</Link>{' '}
to check if your DNS has been propagated successfully before clicking verify.
</p>
- <p>
- Some registrars will require you to remove the domain name when creating DNS
- records. As an example, to create a record for `foo.app.example.com`, you
- would need to create an entry for `foo.app`.
- </p>
+ {isNotVerifiedYet && (
+ <p className="mt-1 text-foreground-lighter">
+ Some registrars will require you to remove the domain name when creating DNS
+ records. As an example, to create a record for `foo.app.example.com`, you
+ would need to create an entry for `foo.app`.
+ </p>
+ )}
</div>
- ) : (
- <p>
- You may also visit{' '}
- <Link
- href={`https://whatsmydns.net/#TXT/${customDomain.hostname}`}
- className="text-brand"
- >
- here
- </Link>{' '}
- to check if your DNS has been propagated successfully before clicking verify.
- </p>
- )}
- </AlertDescription_Shadcn_>
- </Alert_Shadcn_>
- </div>
+ </AlertDescription_Shadcn_>
+ </Alert_Shadcn_>
+ </div>
+ )}
</div>
{hasCAAErrors && (
@@ -139,21 +144,7 @@ const CustomDomainVerify = ({ projectRef, customDomain, settings }: CustomDomain
</Alert_Shadcn_>
) : (
<div className="space-y-2">
- <div className="flex gap-4">
- <div className="w-[50px]">
- <p className="text-foreground-light text-sm">Type</p>
- </div>
- <div className="text-sm grid gap-2 md:grid md:grid-cols-12 md:gap-x-4 input-mono flex-1">
- <div className="flex flex-row space-x-2 justify-between col-span-12">
- <label className="block text-foreground-light text-sm break-all">Name</label>
- </div>
- </div>
- <div className="text-sm grid gap-2 md:grid md:grid-cols-12 md:gap-x-4 input-mono flex-1">
- <div className="flex flex-row space-x-2 justify-between col-span-12">
- <label className="block text-foreground-light text-sm break-all">Content</label>
- </div>
- </div>
- </div>
+ <DNSTableHeaders display={customDomain.ssl.txt_name ?? ''} />
{customDomain.verification_errors?.includes(
'custom hostname does not CNAME to this zone.'
@@ -165,15 +156,7 @@ const CustomDomainVerify = ({ projectRef, customDomain, settings }: CustomDomain
/>
)}
- {customDomain.ownership_verification && (
- <DNSRecord
- type={customDomain.ownership_verification.type}
- name={customDomain.ownership_verification.name}
- value={customDomain.ownership_verification.value}
- />
- )}
-
- {customDomain.ssl.status === 'pending_validation' && (
+ {!isValidating && customDomain.ssl.status === 'pending_validation' && (
<DNSRecord
type="TXT"
name={customDomain.ssl.txt_name ?? 'Loading...'}
@@ -191,18 +174,6 @@ const CustomDomainVerify = ({ projectRef, customDomain, settings }: CustomDomain
)}
</div>
)}
-
- <div className="!mt-4">
- <p className="text-sm text-foreground-light">
- One of the records requires you to{' '}
- <span className="text-foreground-light">replace</span> the CNAME record set up in the
- first step with a TXT record.
- </p>
- <p className="text-sm text-foreground-light">
- You'll be able to restore it back to the CNAME after the verification process has been
- completed.
- </p>
- </div>
</Panel.Content>
<div className="border-t border-muted" />
@@ -222,8 +193,7 @@ const CustomDomainVerify = ({ projectRef, customDomain, settings }: CustomDomain
<Button
type="default"
onClick={onCancelCustomDomain}
- loading={isDeleting}
- disabled={isDeleting || isReverifyLoading}
+ disabled={isDeleting || isReverifyLoading || isValidating}
className="self-end"
>
Cancel
@@ -231,8 +201,8 @@ const CustomDomainVerify = ({ projectRef, customDomain, settings }: CustomDomain
<Button
icon={<RefreshCw />}
onClick={onReverifyCustomDomain}
- loading={isReverifyLoading}
- disabled={isDeleting || isReverifyLoading}
+ loading={!isValidating && isReverifyLoading}
+ disabled={isDeleting || isReverifyLoading || isValidating}
className="self-end"
>
Verify
diff --git a/apps/studio/components/interfaces/Settings/General/CustomDomainConfig/CustomDomainsConfigureHostname.tsx b/apps/studio/components/interfaces/Settings/General/CustomDomainConfig/CustomDomainsConfigureHostname.tsx
index 392a993e6ac..23105004928 100644
--- a/apps/studio/components/interfaces/Settings/General/CustomDomainConfig/CustomDomainsConfigureHostname.tsx
+++ b/apps/studio/components/interfaces/Settings/General/CustomDomainConfig/CustomDomainsConfigureHostname.tsx
@@ -93,7 +93,7 @@ const CustomDomainsConfigureHostname = () => {
<FormSectionContent loading={false}>
<Input
id="domain"
- disabled={!canConfigureCustomDomain}
+ disabled={!canConfigureCustomDomain || isCheckingRecord || isCreating}
className="w-full"
type="text"
name="domain"
@@ -108,14 +108,14 @@ const CustomDomainsConfigureHostname = () => {
<code className="text-xs">{values.domain}</code>
) : (
'your custom domain'
- )}
- , resolving to{' '}
+ )}{' '}
+ resolving to{' '}
{endpoint ? (
<code className="text-xs">{endpoint}</code>
) : (
"your project's API URL"
- )}
- , with as low a TTL as possible. If you're using Cloudflare as your DNS provider,
+ )}{' '}
+ with as low a TTL as possible. If you're using Cloudflare as your DNS provider,
disable the proxy option.
</p>
</FormSection>
diff --git a/apps/studio/components/interfaces/Settings/General/CustomDomainConfig/DNSTableHeaders.tsx b/apps/studio/components/interfaces/Settings/General/CustomDomainConfig/DNSTableHeaders.tsx
new file mode 100644
index 00000000000..2c860fa0715
--- /dev/null
+++ b/apps/studio/components/interfaces/Settings/General/CustomDomainConfig/DNSTableHeaders.tsx
@@ -0,0 +1,38 @@
+import { Loader2 } from 'lucide-react'
+
+export type DNSTableHeaderProps = {
+ display: string
+}
+
+export const DNSTableHeaders = ({ display }: DNSTableHeaderProps) => {
+ // Display the DNS table headers if we have something to show
+ if (display !== '') {
+ return (
+ <div className="flex gap-4">
+ <div className="w-[50px]">
+ <p className="text-foreground-light text-sm">Type</p>
+ </div>
+ <div className="text-sm grid gap-2 md:grid md:grid-cols-12 md:gap-x-4 input-mono flex-1">
+ <div className="flex flex-row space-x-2 justify-between col-span-12">
+ <label className="block text-foreground-light text-sm break-all">Name</label>
+ </div>
+ </div>
+ <div className="text-sm grid gap-2 md:grid md:grid-cols-12 md:gap-x-4 input-mono flex-1">
+ <div className="flex flex-row space-x-2 justify-between col-span-12">
+ <label className="block text-foreground-light text-sm break-all">Content</label>
+ </div>
+ </div>
+ </div>
+ )
+ }
+
+ // If we have not detected SSL TXT records ask the user to (re)validate
+ return (
+ <div className="flex items-center gap-2">
+ <Loader2 size={14} className="animate-spin" />
+ <p className="text-sm text-foreground-light">
+ Validating custom domain and TLS configuration...
+ </p>
+ </div>
+ )
+}
diff --git a/apps/studio/data/custom-domains/custom-domains-query.ts b/apps/studio/data/custom-domains/custom-domains-query.ts
index 1ffd8cd0f8e..f4ab2ee06fc 100644
--- a/apps/studio/data/custom-domains/custom-domains-query.ts
+++ b/apps/studio/data/custom-domains/custom-domains-query.ts
@@ -19,7 +19,7 @@ type Ssl = {
id: string
type: string
method: string
- status: 'pending_validation' | 'pending_deployment' | 'validation_timed_out'
+ status: 'pending_validation' | 'pending_deployment' | 'validation_timed_out' | 'initializing'
txt_name?: string
txt_value?: string
settings: Settings
diff --git a/apps/studio/hooks/misc/useInterval.ts b/apps/studio/hooks/misc/useInterval.ts
new file mode 100644
index 00000000000..3e72cd2aca2
--- /dev/null
+++ b/apps/studio/hooks/misc/useInterval.ts
@@ -0,0 +1,23 @@
+import { useEffect, useRef } from 'react'
+
+export function useInterval(callback: () => void, delay: number | false) {
+ const savedCallback = useRef(callback)
+
+ useEffect(() => {
+ savedCallback.current = callback
+ }, [callback])
+
+ useEffect(() => {
+ if (delay === false) {
+ return
+ }
+
+ const id = setInterval(() => {
+ savedCallback.current()
+ }, delay)
+
+ return () => {
+ clearInterval(id)
+ }
+ }, [delay])
+}