anomalyco/sst · error · Error

Record name "${recordName}" is not a subdomain of "${domain}

Error message

Record name "${recordName}" is not a subdomain of "${domain}".

What it means

When creating a DNS record for a Vercel-managed domain, validateRecordName checks that the requested record name ends with the domain being managed; it then strips the domain suffix to compute the relative record name. This error means the record's name is not a subdomain of the configured Vercel domain, so Vercel DNS cannot own/create it.

Source

Thrown at platform/src/components/vercel/dns.ts:145

      ),
    ];
  }

  function createRecord(
    namePrefix: string,
    record: Record,
    opts: ComponentResourceOptions,
  ) {
    return all([args.domain, record]).apply(([domain, record]) => {
      const nameSuffix = logicalName(record.name);
      const recordName = validateRecordName();
      const dnsRecord = createRecord();
      return dnsRecord;

      function validateRecordName() {
        const recordName = record.name.replace(/\.$/, "");
        if (!recordName.endsWith(domain))
          throw new Error(
            `Record name "${recordName}" is not a subdomain of "${domain}".`,
          );
        return recordName.slice(0, -(domain.length + 1));
      }

      function createRecord() {
        return new DnsRecord(
          ...transform(
            args.transform?.record,
            `${namePrefix}${record.type}Record${nameSuffix}`,
            {
              domain: args.domain,
              type: record.type,
              name: recordName,
              value: record.value,
              mxPriority: record.priority,
              teamId: DEFAULT_TEAM_ID,
              ttl: 60,

View on GitHub (pinned to a0bd20f762)

Solutions

  1. Make record.name a subdomain of the domain the Vercel DNS component is configured with, e.g. name: 'api' with domain 'example.com', or name: 'api.example.com'.
  2. Check for typos or mismatched TLDs between record.name and domain ('.org' vs '.com').
  3. Remove a trailing dot mismatch: the code strips one trailing '.', so 'api.example.com.' works but other whitespace does not — trim the input.
  4. If you need a record outside this domain, use a different DNS provider/component that manages that domain instead.

Example fix

// before
new sst.vercel.DnsRecord(ctx, "dns", { domain: "example.com", record: { name: "api.myapp.com", type: "CNAME", value: target } });
// after
new sst.vercel.DnsRecord(ctx, "dns", { domain: "example.com", record: { name: "api.example.com", type: "CNAME", value: target } });
Defensive patterns

Strategy: validation

Validate before calling

const name = record.name.replace(/\.$/, "");
if (!name.endsWith(domain)) throw new Error(`record ${name} is not a subdomain of ${domain}`);

Type guard

function isSubdomainOf(recordName: string, domain: string): boolean {
  return recordName.replace(/\.$/, "").endsWith(domain);
}

Try / catch

try {
  await createDnsRecord({ domain, record });
} catch (e) {
  if ((e as Error).message.includes("is not a subdomain of")) {
    throw new Error(`Record "${record.name}" must live under "${domain}"; check domain/record name`, { cause: e });
  }
  throw e;
}

Prevention

When it happens

Trigger: Creating a sst vercel DNS record where record.name does not end with the configured domain string — e.g. record name 'api.example.com' while domain is 'other.com', or a trailing-dot/typo mismatch like 'api.example.org' vs domain 'example.com'.

Common situations: Typos in the domain or record name, using an apex domain record ('example.com') where the code expects a subdomain plus suffix, pointing a record at a domain registered elsewhere, or copy-pasting a record name from another project.

Related errors


AI-assisted analysis of anomalyco/sst@a0bd20f762 (2026-08-30). Data as JSON: /api/errors/fc51d0c369b63d25. Report an issue: GitHub.