fix: resolve @ to the zone's apex domain before sending it to the provider

Route53 rejects the literal "@" (RRSet with DNS name @. is not
permitted); Cloudflare happens to accept it, but relying on
provider-specific handling of that shorthand isn't safe. Resolve it
client-side to the zone's actual domain name before building the
create/update payload.
This commit is contained in:
Mauricio Siu
2026-08-12 03:35:11 -06:00
parent 16f0f0eeb4
commit 37f0bba43f
2 changed files with 18 additions and 4 deletions
@@ -54,10 +54,16 @@ interface DnsRecordValue {
interface Props {
dnsProviderId: string;
zoneId: string;
zoneName: string;
record?: DnsRecordValue;
}
export const HandleDnsRecord = ({ dnsProviderId, zoneId, record }: Props) => {
export const HandleDnsRecord = ({
dnsProviderId,
zoneId,
zoneName,
record,
}: Props) => {
const utils = api.useUtils();
const [isOpen, setIsOpen] = useState(false);
@@ -102,11 +108,12 @@ export const HandleDnsRecord = ({ dnsProviderId, zoneId, record }: Props) => {
const type = form.watch("type");
const onSubmit = async (data: DnsRecordForm) => {
const name = data.name.trim() === "@" ? zoneName : data.name;
const payload = {
dnsProviderId,
zoneId,
type: data.type,
name: data.name,
name,
content: data.content,
ttl: data.ttl ? Number(data.ttl) : undefined,
...(record && { recordId: record.id }),
@@ -24,9 +24,10 @@ import { HandleDnsRecord } from "./handle-dns-record";
interface ZoneRecordsProps {
dnsProviderId: string;
zoneId: string;
zoneName: string;
}
const ZoneRecords = ({ dnsProviderId, zoneId }: ZoneRecordsProps) => {
const ZoneRecords = ({ dnsProviderId, zoneId, zoneName }: ZoneRecordsProps) => {
const utils = api.useUtils();
const { data, isLoading, isError, error } =
api.dnsProvider.listRecords.useQuery({ dnsProviderId, zoneId });
@@ -71,6 +72,7 @@ const ZoneRecords = ({ dnsProviderId, zoneId }: ZoneRecordsProps) => {
<HandleDnsRecord
dnsProviderId={dnsProviderId}
zoneId={zoneId}
zoneName={zoneName}
record={record}
/>
)}
@@ -112,7 +114,11 @@ const ZoneRecords = ({ dnsProviderId, zoneId }: ZoneRecordsProps) => {
})}
{canWrite && (
<div className="pt-1">
<HandleDnsRecord dnsProviderId={dnsProviderId} zoneId={zoneId} />
<HandleDnsRecord
dnsProviderId={dnsProviderId}
zoneId={zoneId}
zoneName={zoneName}
/>
</div>
)}
</div>
@@ -198,6 +204,7 @@ export const ShowDnsProviderZones = ({
<ZoneRecords
dnsProviderId={dnsProviderId}
zoneId={zone.id}
zoneName={zone.name}
/>
)}
</div>