The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
refactors custom domains code
Alaister Young0bfa058b759c
diff --git a/studio/components/interfaces/Settings/API/CustomDomainConfig.tsx b/studio/components/interfaces/Settings/API/CustomDomainConfig.tsxdeleted file mode 100644index da2a2fbd9f8..00000000000--- a/studio/components/interfaces/Settings/API/CustomDomainConfig.tsx+++ /dev/null@@ -1,469 +0,0 @@-import ConfirmModal from 'components/ui/Dialogs/ConfirmDialog'-import {- FormActions,- FormPanel,- FormSection,- FormSectionContent,- FormSectionLabel,-} from 'components/ui/Forms'-import Panel from 'components/ui/Panel'-import { useProjectSettingsQuery } from 'data/config/project-settings-query'-import { useCustomDomainActivateMutation } from 'data/custom-domains/custom-domains-activate-mutation'-import { useCustomDomainCreateMutation } from 'data/custom-domains/custom-domains-create-mutation'-import { useCustomDomainDeleteMutation } from 'data/custom-domains/custom-domains-delete-mutation'-import { useCustomDomainsQuery } from 'data/custom-domains/custom-domains-query'-import { useCustomDomainReverifyMutation } from 'data/custom-domains/custom-domains-reverify-mutation'-import { useParams, useStore } from 'hooks'-import { observer } from 'mobx-react-lite'-import Link from 'next/link'-import { useState } from 'react'-import {- Alert,- Button,- Form,- IconAlertCircle,- IconExternalLink,- IconRefreshCw,- IconTrash,- Input,-} from 'ui'-import * as yup from 'yup'--const FORM_ID = 'custom-domains-form'--const CUSTOM_DOMAINS_TITLE = (- <div className="flex-1 flex items-center justify-between">- <h5 className="mb-0">Custom Domain</h5>-- <a- href="https://supabase.com/docs/guides/platform/custom-domains"- target="_blank"- rel="noreferrer noopener"- className="flex items-center gap-1 text-sm text-scale-1000 hover:text-scale-1100"- >- <span>Docs</span>- <IconExternalLink className="inline w-4 h-4" />- </a>- </div>-)--const schema = yup.object({- domain: yup.string().required('Custom domain is required'),-})--const CustomDomainConfig = () => {- const { ui } = useStore()- const { ref } = useParams()-- const { isLoading: isSettingsLoading, data: settings } = useProjectSettingsQuery({- projectRef: ref,- })-- const {- isLoading: isCustomDomainsLoading,- isError,- error,- isSuccess,- data,- } = useCustomDomainsQuery(- { projectRef: ref },- {- retry: false,- refetchOnWindowFocus: false,- }- )-- const isLoading = isSettingsLoading || isCustomDomainsLoading-- const isNoHostnameConfiguredError =- isError &&- (error as any)?.code === 400 &&- (error as any)?.message?.includes('custom hostname configuration')-- const isNotAllowedError =- isError &&- (error as any)?.code === 400 &&- (error as any)?.message?.includes('not allowed to set up custom domain')-- const isUnknownError = isError && !isNoHostnameConfiguredError && !isNotAllowedError-- const { mutateAsync: createCustomDomain } = useCustomDomainCreateMutation()-- const onCreateCustomDomain = async (values: yup.InferType<typeof schema>) => {- if (!ref) {- throw new Error('Project ref is required')- }-- try {- await createCustomDomain({- projectRef: ref,- customDomain: values.domain,- })-- ui.setNotification({- category: 'success',- message: `Successfully created custom domain. Please verify the domain by adding the listed records to your domain's DNS settings.`,- duration: 10000,- })- } catch (error: any) {- ui.setNotification({- category: 'error',- message: error.message,- })- }- }-- const { mutate: reverifyCustomDomain, isLoading: isReverifyLoading } =- useCustomDomainReverifyMutation()-- const onReverifyCustomDomain = () => {- if (!ref) {- throw new Error('Project ref is required')- }-- reverifyCustomDomain({ projectRef: ref })- }-- const [isActivateConfirmModalVisible, setIsActivateConfirmModalVisible] = useState(false)-- const { mutateAsync: activateCustomDomain } = useCustomDomainActivateMutation()-- const onActivateCustomDomain = async () => {- if (!ref) {- throw new Error('Project ref is required')- }-- try {- await activateCustomDomain({ projectRef: ref })-- ui.setNotification({- category: 'success',- message: `Successfully activated custom domain`,- })-- setIsActivateConfirmModalVisible(false)- } catch (error: any) {- ui.setNotification({- category: 'error',- message: error.message,- })- }- }-- const [isDeleteConfirmModalVisible, setIsDeleteConfirmModalVisible] = useState(false)-- const { mutateAsync: deleteCustomDomain } = useCustomDomainDeleteMutation()-- const onDeleteCustomDomain = async () => {- if (!ref) {- throw new Error('Project ref is required')- }-- try {- await deleteCustomDomain({ projectRef: ref })-- ui.setNotification({- category: 'success',- message: `Successfully deleted custom domain`,- })-- setIsDeleteConfirmModalVisible(false)- } catch (error: any) {- ui.setNotification({- category: 'error',- message: error.message,- })- }- }-- if (isNoHostnameConfiguredError) {- return (- <Form- id={FORM_ID}- initialValues={{ domain: '' }}- validationSchema={schema}- onSubmit={onCreateCustomDomain}- >- {({ isSubmitting, handleReset, values, initialValues }: any) => {- const hasChanges = JSON.stringify(values) !== JSON.stringify(initialValues)-- return (- <>- <FormPanel- disabled={true}- header={CUSTOM_DOMAINS_TITLE}- footer={- <div className="flex py-4 px-8">- <FormActions- form={FORM_ID}- isSubmitting={isSubmitting}- submitText="Add"- hasChanges={hasChanges}- handleReset={handleReset}- disabled={!true}- helper={- !true- ? "You need additional permissions to update your project's custom domain settings"- : undefined- }- />- </div>- }- >- <FormSection header={<FormSectionLabel>Add a Custom Domain</FormSectionLabel>}>- <FormSectionContent loading={false}>- <Input- id="domain"- className="w-full"- type="text"- name="domain"- placeholder="subdomain.example.com"- />-- <Alert- withIcon- variant="info"- title="Setup CNAME record before adding a custom domain"- >- Create a CNAME record in your DNS provider pointing to{' '}- <code>{settings?.autoApiService.app_config.endpoint ?? 'Loading...'}</code>,- then add your custom domain above.- </Alert>- </FormSectionContent>- </FormSection>- </FormPanel>- </>- )- }}- </Form>- )- }-- return (- <>- <Panel title={CUSTOM_DOMAINS_TITLE}>- <Panel.Content className="space-y-6 border-t border-panel-border-interior-light dark:border-panel-border-interior-dark">- {isLoading && <CustomDomainsShimmerLoader />}-- {isNotAllowedError && (- <div className="flex items-center justify-center space-x-2 py-8">- <IconAlertCircle size={16} strokeWidth={1.5} />- <p className="text-sm text-scale-1100">- Custom domain is not enabled for this project. Please{' '}- <Link href={`/support/new?ref=${ref}&category=sales`}>- <a className="underline">contact support</a>- </Link>{' '}- if you would like to enable this feature.- </p>- </div>- )}-- {isUnknownError && (- <div className="flex items-center justify-center space-x-2 py-8">- <IconAlertCircle size={16} strokeWidth={1.5} />- <p className="text-sm text-scale-1100">- Failed to retrieve custom domain configuration. Please try again later or{' '}- <Link href={`/support/new?ref=${ref}&category=sales`}>- <a className="underline">contact support</a>- </Link>- .- </p>- </div>- )}-- {isSuccess && (- <div className="flex flex-col gap-6">- {(data.status === '2_initiated' || data.status === '3_challenge_verified') && (- <>- <div>- <h4 className="text-scale-1200">- Set the following record(s) in your DNS provider:- </h4>- <span className="text-sm text-scale-1100">- Please note that it may take up to 24 hours for the DNS records to propagate.- </span>- </div>-- {data.customDomain.verification_errors?.includes(- 'custom hostname does not CNAME to this zone.'- ) && (- <DNSRecord- type="CNAME"- name={data.customDomain.hostname}- value={settings?.autoApiService.app_config.endpoint ?? 'Loading...'}- />- )}-- {data.customDomain.ownership_verification && (- <DNSRecord- type={data.customDomain.ownership_verification.type}- name={data.customDomain.ownership_verification.name}- value={data.customDomain.ownership_verification.value}- />- )}-- {data.customDomain.ssl.status === 'pending_validation' && (- <DNSRecord- type="TXT"- name={data.customDomain.ssl.txt_name ?? 'Loading...'}- value={data.customDomain.ssl.txt_value ?? 'Loading...'}- />- )}-- {- <Button- icon={<IconRefreshCw />}- onClick={onReverifyCustomDomain}- loading={isReverifyLoading}- className="self-end"- >- Verify- </Button>- }- </>- )}-- {data.status === '4_origin_setup_completed' && (- <div className="flex flex-col items-start gap-6">- <div className="flex flex-col gap-1">- <h4 className="text-scale-1200">- Setup complete! Press activate to enable {data.customDomain.hostname} for this- project.- </h4>-- <span className="text-sm text-scale-1100">- Supabase recommends that your schedule a downtime window of 20-30 minutes for- your application, as you will need to update any client code (e.g., frontends,- mobile apps), and any OAuth providers (e.g., google, github) that use the- current supabase subdomain.- </span>- </div>-- <Button- icon={- <svg- xmlns="http://www.w3.org/2000/svg"- fill="none"- viewBox="0 0 24 24"- strokeWidth={1}- stroke="currentColor"- className="w-4 h-4"- >- <path- strokeLinecap="round"- strokeLinejoin="round"- d="M3.75 13.5l10.5-11.25L12 10.5h8.25L9.75 21.75 12 13.5H3.75z"- />- </svg>- }- onClick={() => setIsActivateConfirmModalVisible(true)}- className="self-end"- >- Activate- </Button>- </div>- )}-- {data.status === '5_services_reconfigured' && (- <div className="flex items-center justify-between">- <div>- <code className="text-sm bg-green-400">{data.customDomain.hostname}</code> is- activate and serving traffic.- </div>-- <Button- type="danger"- icon={<IconTrash />}- onClick={() => setIsDeleteConfirmModalVisible(true)}- >- Delete Custom Domain- </Button>- </div>- )}- </div>- )}- </Panel.Content>- </Panel>-- <ConfirmModal- visible={isActivateConfirmModalVisible}- title={`Are you sure you want to activate ${- data?.customDomain.hostname ?? 'your custom hostname'- }?`}- description="Your existing supabase subdomain will be deactivated."- buttonLabel="Activate"- buttonLoadingLabel="Activating"- onSelectCancel={() => setIsActivateConfirmModalVisible(false)}- onSelectConfirm={onActivateCustomDomain}- />-- <ConfirmModal- danger- visible={isDeleteConfirmModalVisible}- title={`Are you sure you want to delete ${- data?.customDomain.hostname ?? 'your custom hostname'- }?`}- description="Your custom domain will be deactivated. You will need to re-verify your domain if you want to use it again."- buttonLabel="Delete"- buttonLoadingLabel="Deleting"- onSelectCancel={() => setIsDeleteConfirmModalVisible(false)}- onSelectConfirm={onDeleteCustomDomain}- />- </>- )-}--export default observer(CustomDomainConfig)--type DNSRecordProps = {- type: string- name: string- value: string-}--const DNSRecord = ({ type, name, value }: DNSRecordProps) => {- return (- <div className="flex gap-4">- <Input- label="Type"- readOnly- disabled- className="input-mono"- value={type.toUpperCase()}- layout="vertical"- />- <Input- label="Name"- readOnly- copy- disabled- className="input-mono flex-1"- value={name}- layout="vertical"- />- <Input- label="Value"- readOnly- copy- disabled- className="input-mono flex-1"- value={value}- layout="vertical"- />- </div>- )-}--const CustomDomainsShimmerLoader = () => {- return (- <div className="grid grid-cols-12 gap-6 px-8 py-8">- <div className="col-span-12 lg:col-span-5">- <div className="h-6 w-1/3 bg-scale-1000 rounded shimmering-loader" />- </div>-- <div className="col-span-12 lg:col-span-7">- <div className="h-[38px] w-full bg-scale-1000 rounded shimmering-loader" />- </div>- </div>- )-}diff --git a/studio/components/interfaces/Settings/API/CustomDomainConfig/CustomDomainActivate.tsx b/studio/components/interfaces/Settings/API/CustomDomainConfig/CustomDomainActivate.tsxnew file mode 100644index 00000000000..9ac592e5020--- /dev/null+++ b/studio/components/interfaces/Settings/API/CustomDomainConfig/CustomDomainActivate.tsx@@ -0,0 +1,95 @@+import ConfirmModal from 'components/ui/Dialogs/ConfirmDialog'+import { useCustomDomainActivateMutation } from 'data/custom-domains/custom-domains-activate-mutation'+import { CustomDomainResponse } from 'data/custom-domains/custom-domains-query'+import { useStore } from 'hooks'+import { observer } from 'mobx-react-lite'+import { useState } from 'react'+import { Button } from 'ui'++export type CustomDomainActivateProps = {+ projectRef?: string+ customDomain: CustomDomainResponse+}++const CustomDomainActivate = ({ projectRef, customDomain }: CustomDomainActivateProps) => {+ const { ui } = useStore()++ const [isActivateConfirmModalVisible, setIsActivateConfirmModalVisible] = useState(false)++ const { mutateAsync: activateCustomDomain } = useCustomDomainActivateMutation()++ const onActivateCustomDomain = async () => {+ if (!projectRef) {+ throw new Error('Project ref is required')+ }++ try {+ await activateCustomDomain({ projectRef })++ ui.setNotification({+ category: 'success',+ message: `Successfully activated custom domain`,+ })++ setIsActivateConfirmModalVisible(false)+ } catch (error: any) {+ ui.setNotification({+ category: 'error',+ message: error.message,+ })+ }+ }++ return (+ <>+ <div className="flex flex-col items-start gap-6">+ <div className="flex flex-col gap-1">+ <h4 className="text-scale-1200">+ Setup complete! Press activate to enable {customDomain.hostname} for this project.+ </h4>++ <span className="text-sm text-scale-1100">+ Supabase recommends that your schedule a downtime window of 20-30 minutes for your+ application, as you will need to update any client code (e.g., frontends, mobile apps),+ and any OAuth providers (e.g., google, github) that use the current supabase subdomain.+ </span>+ </div>++ <Button+ icon={+ <svg+ xmlns="http://www.w3.org/2000/svg"+ fill="none"+ viewBox="0 0 24 24"+ strokeWidth={1}+ stroke="currentColor"+ className="w-4 h-4"+ >+ <path+ strokeLinecap="round"+ strokeLinejoin="round"+ d="M3.75 13.5l10.5-11.25L12 10.5h8.25L9.75 21.75 12 13.5H3.75z"+ />+ </svg>+ }+ onClick={() => setIsActivateConfirmModalVisible(true)}+ className="self-end"+ >+ Activate+ </Button>+ </div>++ <ConfirmModal+ visible={isActivateConfirmModalVisible}+ title={`Are you sure you want to activate ${customDomain.hostname}?`}+ description="Your existing supabase subdomain will be deactivated."+ buttonLabel="Activate"+ buttonLoadingLabel="Activating"+ onSelectCancel={() => setIsActivateConfirmModalVisible(false)}+ onSelectConfirm={onActivateCustomDomain}+ />+ </>+ )+}++export default observer(CustomDomainActivate)diff --git a/studio/components/interfaces/Settings/API/CustomDomainConfig/CustomDomainConfig.tsx b/studio/components/interfaces/Settings/API/CustomDomainConfig/CustomDomainConfig.tsxnew file mode 100644index 00000000000..ca8cf701205--- /dev/null+++ b/studio/components/interfaces/Settings/API/CustomDomainConfig/CustomDomainConfig.tsx@@ -0,0 +1,132 @@+import Panel from 'components/ui/Panel'+import { useProjectSettingsQuery } from 'data/config/project-settings-query'+import { useCustomDomainsQuery } from 'data/custom-domains/custom-domains-query'+import { useParams } from 'hooks'+import { observer } from 'mobx-react-lite'+import Link from 'next/link'+import { IconAlertCircle, IconExternalLink } from 'ui'+import CustomDomainActivate from './CustomDomainActivate'+import CustomDomainDelete from './CustomDomainDelete'+import CustomDomainsConfigureHostname from './CustomDomainsConfigureHostname'+import CustomDomainsShimmerLoader from './CustomDomainsShimmerLoader'+import CustomDomainVerify from './CustomDomainVerify'++const CustomDomainConfig = () => {+ const { ref } = useParams()++ const { isLoading: isSettingsLoading, data: settings } = useProjectSettingsQuery({+ projectRef: ref,+ })++ const {+ isLoading: isCustomDomainsLoading,+ isError,+ error,+ isSuccess,+ data,+ } = useCustomDomainsQuery(+ { projectRef: ref },+ {+ retry: false,+ refetchOnWindowFocus: false,+ }+ )++ const isLoading = isSettingsLoading || isCustomDomainsLoading++ const isNoHostnameConfiguredError =+ isError &&+ (error as any)?.code === 400 &&+ (error as any)?.message?.includes('custom hostname configuration')++ const isNotAllowedError =+ isError &&+ (error as any)?.code === 400 &&+ (error as any)?.message?.includes('not allowed to set up custom domain')++ const isUnknownError = isError && !isNoHostnameConfiguredError && !isNotAllowedError++ if (isNoHostnameConfiguredError) {+ return (+ <CustomDomainsConfigureHostname+ projectRef={ref}+ title={CUSTOM_DOMAINS_TITLE}+ settings={settings}+ />+ )+ }++ return (+ <>+ <Panel title={CUSTOM_DOMAINS_TITLE}>+ <Panel.Content className="space-y-6 border-t border-panel-border-interior-light dark:border-panel-border-interior-dark">+ {isLoading && <CustomDomainsShimmerLoader />}++ {isNotAllowedError && (+ <div className="flex items-center justify-center space-x-2 py-8">+ <IconAlertCircle size={16} strokeWidth={1.5} />+ <p className="text-sm text-scale-1100">+ Custom domain is not enabled for this project. Please{' '}+ <Link href={`/support/new?ref=${ref}&category=sales`}>+ <a className="underline">contact support</a>+ </Link>{' '}+ if you would like to enable this feature.+ </p>+ </div>+ )}++ {isUnknownError && (+ <div className="flex items-center justify-center space-x-2 py-8">+ <IconAlertCircle size={16} strokeWidth={1.5} />+ <p className="text-sm text-scale-1100">+ Failed to retrieve custom domain configuration. Please try again later or{' '}+ <Link href={`/support/new?ref=${ref}&category=sales`}>+ <a className="underline">contact support</a>+ </Link>+ .+ </p>+ </div>+ )}++ {isSuccess && (+ <div className="flex flex-col gap-6">+ {(data.status === '2_initiated' || data.status === '3_challenge_verified') && (+ <CustomDomainVerify+ projectRef={ref}+ customDomain={data.customDomain}+ settings={settings}+ />+ )}++ {data.status === '4_origin_setup_completed' && (+ <CustomDomainActivate projectRef={ref} customDomain={data.customDomain} />+ )}++ {data.status === '5_services_reconfigured' && (+ <CustomDomainDelete projectRef={ref} customDomain={data.customDomain} />+ )}+ </div>+ )}+ </Panel.Content>+ </Panel>+ </>+ )+}++export default observer(CustomDomainConfig)++const CUSTOM_DOMAINS_TITLE = (+ <div className="flex-1 flex items-center justify-between">+ <h5 className="mb-0">Custom Domain</h5>++ <a+ href="https://supabase.com/docs/guides/platform/custom-domains"+ target="_blank"+ rel="noreferrer noopener"+ className="flex items-center gap-1 text-sm text-scale-1000 hover:text-scale-1100"+ >+ <span>Docs</span>+ <IconExternalLink className="inline w-4 h-4" />+ </a>+ </div>+)diff --git a/studio/components/interfaces/Settings/API/CustomDomainConfig/CustomDomainDelete.tsx b/studio/components/interfaces/Settings/API/CustomDomainConfig/CustomDomainDelete.tsxnew file mode 100644index 00000000000..27624328719--- /dev/null+++ b/studio/components/interfaces/Settings/API/CustomDomainConfig/CustomDomainDelete.tsx@@ -0,0 +1,74 @@+import ConfirmModal from 'components/ui/Dialogs/ConfirmDialog'+import { useCustomDomainDeleteMutation } from 'data/custom-domains/custom-domains-delete-mutation'+import { CustomDomainResponse } from 'data/custom-domains/custom-domains-query'+import { useStore } from 'hooks'+import { observer } from 'mobx-react-lite'+import { useState } from 'react'+import { Button, IconTrash } from 'ui'++export type CustomDomainDeleteProps = {+ projectRef?: string+ customDomain: CustomDomainResponse+}++const CustomDomainDelete = ({ projectRef, customDomain }: CustomDomainDeleteProps) => {+ const { ui } = useStore()++ const [isDeleteConfirmModalVisible, setIsDeleteConfirmModalVisible] = useState(false)++ const { mutateAsync: deleteCustomDomain } = useCustomDomainDeleteMutation()++ const onDeleteCustomDomain = async () => {+ if (!projectRef) {+ throw new Error('Project ref is required')+ }++ try {+ await deleteCustomDomain({ projectRef })++ ui.setNotification({+ category: 'success',+ message: `Successfully deleted custom domain`,+ })++ setIsDeleteConfirmModalVisible(false)+ } catch (error: any) {+ ui.setNotification({+ category: 'error',+ message: error.message,+ })+ }+ }++ return (+ <>+ <div className="flex items-center justify-between">+ <div>+ <code className="text-sm bg-green-400">{customDomain.hostname}</code> is activate and+ serving traffic.+ </div>++ <Button+ type="danger"+ icon={<IconTrash />}+ onClick={() => setIsDeleteConfirmModalVisible(true)}+ >+ Delete Custom Domain+ </Button>+ </div>++ <ConfirmModal+ danger+ visible={isDeleteConfirmModalVisible}+ title={`Are you sure you want to delete ${customDomain.hostname}?`}+ description="Your custom domain will be deactivated. You will need to re-verify your domain if you want to use it again."+ buttonLabel="Delete"+ buttonLoadingLabel="Deleting"+ onSelectCancel={() => setIsDeleteConfirmModalVisible(false)}+ onSelectConfirm={onDeleteCustomDomain}+ />+ </>+ )+}++export default observer(CustomDomainDelete)diff --git a/studio/components/interfaces/Settings/API/CustomDomainConfig/CustomDomainVerify.tsx b/studio/components/interfaces/Settings/API/CustomDomainConfig/CustomDomainVerify.tsxnew file mode 100644index 00000000000..87d2b437167--- /dev/null+++ b/studio/components/interfaces/Settings/API/CustomDomainConfig/CustomDomainVerify.tsx@@ -0,0 +1,84 @@+import { ProjectSettingsResponse } from 'data/config/project-settings-query'+import { CustomDomainResponse } from 'data/custom-domains/custom-domains-query'+import { useCustomDomainReverifyMutation } from 'data/custom-domains/custom-domains-reverify-mutation'+import { observer } from 'mobx-react-lite'+import { Button, IconAlertCircle, IconRefreshCw } from 'ui'+import DNSRecord from './DNSRecord'++export type CustomDomainVerifyProps = {+ projectRef?: string+ customDomain: CustomDomainResponse+ settings?: ProjectSettingsResponse+}++const CustomDomainVerify = ({ projectRef, customDomain, settings }: CustomDomainVerifyProps) => {+ const { mutate: reverifyCustomDomain, isLoading: isReverifyLoading } =+ useCustomDomainReverifyMutation()++ const onReverifyCustomDomain = () => {+ if (!projectRef) {+ throw new Error('Project ref is required')+ }++ reverifyCustomDomain({ projectRef })+ }++ return (+ <>+ <div>+ <h4 className="text-scale-1200">Set the following record(s) in your DNS provider:</h4>+ <span className="text-sm text-scale-1100">+ Please note that it may take up to 24 hours for the DNS records to propagate.+ </span>+ </div>++ {customDomain.verification_errors?.includes(+ 'custom hostname does not CNAME to this zone.'+ ) && (+ <DNSRecord+ type="CNAME"+ name={customDomain.hostname}+ value={settings?.autoApiService.app_config.endpoint ?? 'Loading...'}+ />+ )}++ {customDomain.ownership_verification && (+ <DNSRecord+ type={customDomain.ownership_verification.type}+ name={customDomain.ownership_verification.name}+ value={customDomain.ownership_verification.value}+ />+ )}++ {customDomain.ssl.status === 'pending_validation' && (+ <DNSRecord+ type="TXT"+ name={customDomain.ssl.txt_name ?? 'Loading...'}+ value={customDomain.ssl.txt_value ?? 'Loading...'}+ />+ )}++ {customDomain.ssl.status === 'pending_deployment' && (+ <div className="flex items-center justify-center space-x-2 py-8">+ <IconAlertCircle size={16} strokeWidth={1.5} />+ <p className="text-sm text-scale-1100">+ SSL certificate is being deployed. Please wait a few minutes and try again.+ </p>+ </div>+ )}++ {+ <Button+ icon={<IconRefreshCw />}+ onClick={onReverifyCustomDomain}+ loading={isReverifyLoading}+ className="self-end"+ >+ Verify+ </Button>+ }+ </>+ )+}++export default observer(CustomDomainVerify)diff --git a/studio/components/interfaces/Settings/API/CustomDomainConfig/CustomDomainsConfigureHostname.tsx b/studio/components/interfaces/Settings/API/CustomDomainConfig/CustomDomainsConfigureHostname.tsxnew file mode 100644index 00000000000..0858608dc7b--- /dev/null+++ b/studio/components/interfaces/Settings/API/CustomDomainConfig/CustomDomainsConfigureHostname.tsx@@ -0,0 +1,123 @@+import {+ FormActions,+ FormPanel,+ FormSection,+ FormSectionContent,+ FormSectionLabel,+} from 'components/ui/Forms'+import { ProjectSettingsResponse } from 'data/config/project-settings-query'+import { useCustomDomainCreateMutation } from 'data/custom-domains/custom-domains-create-mutation'+import { useStore } from 'hooks'+import { observer } from 'mobx-react-lite'+import { ReactNode } from 'react'+import { Alert, Form, Input } from 'ui'+import * as yup from 'yup'++const FORM_ID = 'custom-domains-form'++const schema = yup.object({+ domain: yup.string().required('Custom domain is required'),+})++export type CustomDomainsConfigureHostnameProps = {+ projectRef?: string+ title: ReactNode+ settings?: ProjectSettingsResponse+}++const CustomDomainsConfigureHostname = ({+ projectRef,+ title,+ settings,+}: CustomDomainsConfigureHostnameProps) => {+ const { ui } = useStore()++ const { mutateAsync: createCustomDomain } = useCustomDomainCreateMutation()++ const onCreateCustomDomain = async (values: yup.InferType<typeof schema>) => {+ if (!projectRef) {+ throw new Error('Project ref is required')+ }++ try {+ await createCustomDomain({+ projectRef,+ customDomain: values.domain,+ })++ ui.setNotification({+ category: 'success',+ message: `Successfully created custom domain. Please verify the domain by adding the listed records to your domain's DNS settings.`,+ duration: 10000,+ })+ } catch (error: any) {+ ui.setNotification({+ category: 'error',+ message: error.message,+ })+ }+ }++ return (+ <Form+ id={FORM_ID}+ initialValues={{ domain: '' }}+ validationSchema={schema}+ onSubmit={onCreateCustomDomain}+ >+ {({ isSubmitting, handleReset, values, initialValues }: any) => {+ const hasChanges = JSON.stringify(values) !== JSON.stringify(initialValues)++ return (+ <>+ <FormPanel+ disabled={true}+ header={title}+ footer={+ <div className="flex py-4 px-8">+ <FormActions+ form={FORM_ID}+ isSubmitting={isSubmitting}+ submitText="Add"+ hasChanges={hasChanges}+ handleReset={handleReset}+ disabled={!true}+ helper={+ !true+ ? "You need additional permissions to update your project's custom domain settings"+ : undefined+ }+ />+ </div>+ }+ >+ <FormSection header={<FormSectionLabel>Add a Custom Domain</FormSectionLabel>}>+ <FormSectionContent loading={false}>+ <Input+ id="domain"+ className="w-full"+ type="text"+ name="domain"+ placeholder="subdomain.example.com"+ />++ <Alert+ withIcon+ variant="info"+ title="Setup CNAME record before adding a custom domain"+ >+ Create a CNAME record in your DNS provider pointing to{' '}+ <code>{settings?.autoApiService.app_config.endpoint ?? 'Loading...'}</code>,+ then add your custom domain above.+ </Alert>+ </FormSectionContent>+ </FormSection>+ </FormPanel>+ </>+ )+ }}+ </Form>+ )+}++export default observer(CustomDomainsConfigureHostname)diff --git a/studio/components/interfaces/Settings/API/CustomDomainConfig/CustomDomainsShimmerLoader.tsx b/studio/components/interfaces/Settings/API/CustomDomainConfig/CustomDomainsShimmerLoader.tsxnew file mode 100644index 00000000000..3caaa3b1b2c--- /dev/null+++ b/studio/components/interfaces/Settings/API/CustomDomainConfig/CustomDomainsShimmerLoader.tsx@@ -0,0 +1,15 @@+const CustomDomainsShimmerLoader = () => {+ return (+ <div className="grid grid-cols-12 gap-6 px-8 py-8">+ <div className="col-span-12 lg:col-span-5">+ <div className="h-6 w-1/3 bg-scale-1000 rounded shimmering-loader" />+ </div>++ <div className="col-span-12 lg:col-span-7">+ <div className="h-[38px] w-full bg-scale-1000 rounded shimmering-loader" />+ </div>+ </div>+ )+}++export default CustomDomainsShimmerLoaderdiff --git a/studio/components/interfaces/Settings/API/CustomDomainConfig/DNSRecord.tsx b/studio/components/interfaces/Settings/API/CustomDomainConfig/DNSRecord.tsxnew file mode 100644index 00000000000..54064f1052b--- /dev/null+++ b/studio/components/interfaces/Settings/API/CustomDomainConfig/DNSRecord.tsx@@ -0,0 +1,42 @@+import { Input } from 'ui'++export type DNSRecordProps = {+ type: string+ name: string+ value: string+}++const DNSRecord = ({ type, name, value }: DNSRecordProps) => {+ return (+ <div className="flex gap-4">+ <Input+ label="Type"+ readOnly+ disabled+ className="input-mono"+ value={type.toUpperCase()}+ layout="vertical"+ />+ <Input+ label="Name"+ readOnly+ copy+ disabled+ className="input-mono flex-1"+ value={name}+ layout="vertical"+ />+ <Input+ label="Value"+ readOnly+ copy+ disabled+ className="input-mono flex-1"+ value={value}+ layout="vertical"+ />+ </div>+ )+}++export default DNSRecorddiff --git a/studio/components/interfaces/Settings/API/ServiceList.tsx b/studio/components/interfaces/Settings/API/ServiceList.tsxindex 8842ed7e5dd..3eefe1b55a9 100644--- a/studio/components/interfaces/Settings/API/ServiceList.tsx+++ b/studio/components/interfaces/Settings/API/ServiceList.tsx@@ -15,7 +15,7 @@ import PostgrestConfig from './PostgrestConfig'import { DisplayApiSettings } from 'components/ui/ProjectSettings'import { JWT_SECRET_UPDATE_ERROR_MESSAGES } from './API.constants'import JWTSettings from './JWTSettings'-import CustomDomainConfig from './CustomDomainConfig'+import CustomDomainConfig from './CustomDomainConfig/CustomDomainConfig'interface Props {projectRef: stringdiff --git a/studio/data/custom-domains/custom-domains-delete-mutation.ts b/studio/data/custom-domains/custom-domains-delete-mutation.tsindex 3180094b97e..ff8a0dae966 100644--- a/studio/data/custom-domains/custom-domains-delete-mutation.ts+++ b/studio/data/custom-domains/custom-domains-delete-mutation.ts@@ -1,5 +1,6 @@import { useMutation, UseMutationOptions, useQueryClient } from '@tanstack/react-query'import { delete_ } from 'lib/common/fetch'+import { getCustomDomains } from './custom-domains-query'import { customDomainKeys } from './keys'export type CustomDomainDeleteVariables = {@@ -39,7 +40,6 @@ export const useCustomDomainDeleteMutation = ({async onSuccess(data, variables, context) {const { projectRef } = variables- queryClient.removeQueries(customDomainKeys.list(projectRef))await queryClient.invalidateQueries(customDomainKeys.list(projectRef))await onSuccess?.(data, variables, context)