An app's own domain: cut-over and the way back

The step of a move that can strand a shop (platform-app-move.md). The forge serves a verified name and its proxy fetches the certificate; it writes DNS only when asked (below), so the revert is the owner's records, put back by hand in one edit. In order:

  1. Write the old records down first. Every record at the name (A, AAAA, CNAME, ALIAS, and the TTL of each) as the old host serves them today, in the migration issue and with the domain: pass them as old_records ([{type, name, value, ttl?}]) when adding, or later PUT …/app/domains/<host>/old-records with {records} (MCP app_domains keep, with records; in the terminal, o on the domain's screen, type name value [ttl]; …), up to 50, replaced whole. Types: A, AAAA, CNAME, ALIAS, TXT, MX, NS, CAA, SRV. list then shows them as oldRecords. The forge cannot read them for you after the cut.
  2. Add the name (Settings → App → Domains, app_domains add, or POST …/app/domains). The answer lists the TXT proof and the CNAME or ALIAS to publish. Publish the TXT only; the old A/CNAME stays.
  3. Check (check). The sentence says verified, or what is missing. The old site still answers: nothing has moved. GET /__forge/domains/ask?domain=<host> answering 200 is what lets the proxy issue the certificate on the first request (docs/APPS.md, _Your own domain_). On a verified name the check also asks the name for its certificate over TLS and appends the expiry to the sentence (Certificate valid until …, or expired / due within 14 days, or not read yet). The proxy renews on its own; this is where a failed renewal shows. It updates when someone presses Check.
  4. Cut: replace the old A/CNAME with the CNAME/ALIAS the forge gave. The first request to the new name pays for issuing the certificate (a second or two); request it once yourself, over https, before telling anyone.
  5. Revert, one step: read oldRecords from the domain (list) and put those records back. Traffic returns to the old host as each resolver's cache of the new record expires, so keep the TTL low (platform-app-move.md, §6) until the shop is settled. The forge keeps answering at the name until the domain is removed (remove); removing it is only tidiness once DNS no longer points here, and the old host's certificate was never touched.

Editing DNS at the registrar (optional)

The forge edits DNS only when asked, with a credential you hand it by name: set the secret DNS_API_TOKEN (a Cloudflare API token that edits DNS in the zone) for the repository itself. A forge-wide or organization token is not used: it would reach other tenants' zones. Then, as an admin of the repository, the MCP tool app_domains takes three more actions:

The terminal has the same three, on the domains screen (n on an app's deploys screen), for the same admins:

Every edit is audited (app.domain.dns, and the secret read). A failed edit deletes what it put and puts back what it removed; any record it could not put back is named in the answer, to add by hand. Only Cloudflare is supported; the adapter is src/apps/dns_provider.ts. The settings page has no registrar button yet.

Left out, on purpose: other registrars, or read the old records itself: it keeps only what you wrote down (#11719). This closes #11700 as a runbook over a feature that already ships, not as new code.

What keeps these claims true

All in test/app-domains.test.ts:

Claiming a name someone else holds

If a domain lapsed and you registered it, the old holder's row does not block you. POST /api/v1/repos/:owner/:name/app/domains/:host/claim (admin scope) looks up _forge-verify.<host>. When your claim record (forge-verify=<claim token>) is published and the holder's own record is not, the name moves to your app, already verified. Otherwise the answer is 422 name_held with the publish record to add. The decision is the proof's, not the clock's: a holder whose record still stands keeps the name. A resolver failure counts as "still held".

The claimed row is the claimant's: production's environment, its claim token, and no old records, which were the holder's and go with the holder's row. The publish record names the lowercased host the check reads, however the request spelled it. (held is another error's word on this API, so the claim's is name_held.)

In the terminal, the domains screen (n from the deploys screen) has t, "take a name another app holds": type the name and it runs the same action. A held name answers with the TXT record to publish; claim again once it is there. Tests: "a name moves to the app that proves it once the holder's record is gone" in test/app-domains.test.ts and the t key in test/tui-deploys.test.ts.

An unproved name is held for a day

Adding a name holds it for your app while you publish the TXT record, for 24 hours (UNVERIFIED_HOLD_MS in src/core/domains.ts). Until then another app that adds it is told taken. Once the day has run out and the name is still unproved, the next app that adds or claims it takes the row over, with no DNS proof needed, and the clock starts again for that app. A proved name is never taken this way: only a claim by proof (above) moves it.

The TXT token is derived from the host and the app (claimToken), so a record you published keeps working when you remove the name and add it again, or take it back. An app holds at most 50 domains; one more is refused as too_many_domains. Tests: "an unproved row holds its name for the hold" (1 ms before the hold is taken, exactly at the hold the row moves), "a proved name is never taken over by adding it", "an app holds at most 50 domains" in test/core-domains.test.ts, and "an unproved name whose day has run out" in test/app-domains.test.ts.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs