Skip to content

fix(web): always render DNS records in custom domain setup - #2083

Open
richiemcilroy wants to merge 1 commit into
mainfrom
codex/fix-custom-domain-dns-records
Open

fix(web): always render DNS records in custom domain setup#2083
richiemcilroy wants to merge 1 commit into
mainfrom
codex/fix-custom-domain-dns-records

Conversation

@richiemcilroy

@richiemcilroy richiemcilroy commented Aug 5, 2026

Copy link
Copy Markdown
Member

Problem

The custom domain verify step could render with no DNS records and the Check Status button spun indefinitely. Repro path: set up a subdomain whose Vercel config response omits recommended records, or any transient failure in the status check (errors are swallowed and polling suppresses toasts).

Fix

  • checkDomainStatus falls back to Vercel's well-known targets (cname.vercel-dns.com for subdomains, 76.76.21.21 for apex domains) when the config response has no recommendations, and logs failures server-side instead of silently returning an empty result.
  • VerifyStep renders a fallback record card when no recommended records come back, and shows an explicit retry message when the config fails to load entirely.
  • updateDomain normalizes the stored domain (trim + lowercase).
  • remove-domain uses a shared removeDomain helper for the Vercel API call.

Testing

  • Biome + tsc pass on touched files.
  • Manual: enter a subdomain on the custom domain step → the CNAME record (cname.vercel-dns.com) is displayed even if Vercel omits recommendations.

Greptile Summary

The PR makes custom-domain verification display well-known Vercel DNS targets when recommendations are missing, adds an explicit configuration-load error state, normalizes newly stored domains, and extracts Vercel domain deletion into a shared helper.

  • Adds PSL-backed apex/subdomain classification and fallback CNAME/A recommendations.
  • Adds fallback DNS guidance and retry messaging to the verification UI.
  • Normalizes domains before uniqueness checks, Vercel registration, persistence, and status checks.
  • Reuses a shared helper when removing domains from Vercel.

Confidence Score: 4/5

The PR appears safe to merge, with one non-blocking response-handling issue in the extracted Vercel deletion helper.

The DNS fallback and normalization paths are internally consistent, but parsing every DELETE response as JSON can prevent local cleanup when Vercel returns a successful response without a JSON body.

Files Needing Attention: apps/web/actions/organization/domain-utils.ts

Important Files Changed

Filename Overview
apps/web/actions/organization/domain-utils.ts Adds domain classification, fallback DNS recommendations, logging, and a DELETE helper whose unconditional JSON parsing should be hardened.
apps/web/actions/organization/remove-domain.ts Replaces the inline Vercel request with the shared helper while preserving authorization and local cleanup ordering.
apps/web/actions/organization/update-domain.ts Consistently applies trimmed, lowercase domain normalization to lookup, registration, persistence, and verification.
apps/web/app/(org)/dashboard/settings/organization/components/CustomDomainDialog/VerifyStep.tsx Adds explicit load-failure messaging and fallback DNS record rendering without an identified current behavioral defect.
Prompt To Fix All With AI
### Issue 1
apps/web/actions/organization/domain-utils.ts:98
**DELETE response requires JSON body**

If Vercel returns an empty or non-JSON body for this DELETE request, `res.json()` rejects before `removeOrganizationDomain` clears the local domain fields, leaving the organization with stale custom-domain state even when the HTTP request completed.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Reviews (1): Last reviewed commit: "fix(web): always render DNS records in c..." | Re-trigger Greptile

Greptile also left 1 inline comment on this PR.

Context used (3)

The custom domain verify step could render with no DNS records and spin
indefinitely. This happened when Vercel's config response omitted
recommended records (e.g. domains not on Vercel DNS) or when the status
check silently failed, since the UI only renders records from
recommendedCNAME/recommendedIPv4 and polling suppresses error toasts.

- checkDomainStatus now falls back to Vercel's well-known targets
  (cname.vercel-dns.com for subdomains, 76.76.21.21 for apex) when the
  config response has no recommendations, and logs server-side failures
  instead of swallowing them silently.
- VerifyStep renders a fallback record card when no recommended records
  are present, and shows an explicit retry message when the config
  could not be loaded at all.
- updateDomain normalizes the stored domain (trim + lowercase).
- remove-domain uses a shared removeDomain helper for the Vercel call.
@cursor

cursor Bot commented Aug 5, 2026

Copy link
Copy Markdown

Bugbot is not enabled for your account, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

Authorization: `Bearer ${process.env.VERCEL_AUTH_TOKEN}`,
},
},
).then((res) => res.json());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 DELETE response requires JSON body

If Vercel returns an empty or non-JSON body for this DELETE request, res.json() rejects before removeOrganizationDomain clears the local domain fields, leaving the organization with stale custom-domain state even when the HTTP request completed.

Context Used: AGENTS.md (source)

Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/web/actions/organization/domain-utils.ts
Line: 98

Comment:
**DELETE response requires JSON body**

If Vercel returns an empty or non-JSON body for this DELETE request, `res.json()` rejects before `removeOrganizationDomain` clears the local domain fields, leaving the organization with stale custom-domain state even when the HTTP request completed.

**Context Used:** AGENTS.md ([source](https://github.com/capsoftware/cap/blob/main/AGENTS.md))

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant