diff --git a/messages/en-US.json b/messages/en-US.json
index 61ff3ca6..58bbd825 100644
--- a/messages/en-US.json
+++ b/messages/en-US.json
@@ -1255,5 +1255,20 @@
"securityKeyRemoveTitle": "Remove Security Key",
"securityKeyRemoveDescription": "Enter your password to remove the security key \"{name}\"",
"securityKeyNoKeysRegistered": "No security keys registered",
- "securityKeyNoKeysDescription": "Add a security key to enhance your account security"
+ "securityKeyNoKeysDescription": "Add a security key to enhance your account security",
+ "createDomainRequired": "Domain is required",
+ "createDomainAddDnsRecords": "Add DNS Records",
+ "createDomainAddDnsRecordsDescription": "Add the following DNS records to your domain provider to complete the setup.",
+ "createDomainNsRecords": "NS Records",
+ "createDomainRecord": "Record",
+ "createDomainType": "Type:",
+ "createDomainName": "Name:",
+ "createDomainValue": "Value:",
+ "createDomainCnameRecords": "CNAME Records",
+ "createDomainRecordNumber": "Record {number}",
+ "createDomainTxtRecords": "TXT Records",
+ "createDomainSaveTheseRecords": "Save These Records",
+ "createDomainSaveTheseRecordsDescription": "Make sure to save these DNS records as you will not see them again.",
+ "createDomainDnsPropagation": "DNS Propagation",
+ "createDomainDnsPropagationDescription": "DNS changes may take some time to propagate across the internet. This can take anywhere from a few minutes to 48 hours, depending on your DNS provider and TTL settings."
}
diff --git a/server/routers/domain/deleteOrgDomain.ts b/server/routers/domain/deleteOrgDomain.ts
index aea2a2fa..345dafe7 100644
--- a/server/routers/domain/deleteOrgDomain.ts
+++ b/server/routers/domain/deleteOrgDomain.ts
@@ -39,6 +39,38 @@ export async function deleteAccountDomain(
let numOrgDomains: OrgDomains[] | undefined;
await db.transaction(async (trx) => {
+ const [existing] = await trx
+ .select()
+ .from(orgDomains)
+ .where(
+ and(
+ eq(orgDomains.orgId, orgId),
+ eq(orgDomains.domainId, domainId)
+ )
+ )
+ .innerJoin(
+ domains,
+ eq(orgDomains.domainId, domains.domainId)
+ );
+
+ if (!existing) {
+ return next(
+ createHttpError(
+ HttpCode.NOT_FOUND,
+ "Domain not found for this account"
+ )
+ );
+ }
+
+ if (existing.domains.configManaged) {
+ return next(
+ createHttpError(
+ HttpCode.BAD_REQUEST,
+ "Cannot delete a domain that is managed by the config"
+ )
+ );
+ }
+
await trx
.delete(orgDomains)
.where(
diff --git a/src/app/[orgId]/settings/domains/CreateDomainForm.tsx b/src/app/[orgId]/settings/domains/CreateDomainForm.tsx
index aeca2963..74110a52 100644
--- a/src/app/[orgId]/settings/domains/CreateDomainForm.tsx
+++ b/src/app/[orgId]/settings/domains/CreateDomainForm.tsx
@@ -197,11 +197,10 @@ export default function CreateDomainForm({