Skip to content

Commit 37f0bba

Browse files
committed
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.
1 parent 16f0f0e commit 37f0bba

2 files changed

Lines changed: 18 additions & 4 deletions

File tree

‎apps/dokploy/components/dashboard/settings/dns/handle-dns-record.tsx‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,16 @@ interface DnsRecordValue {
5454
interface Props {
5555
dnsProviderId: string;
5656
zoneId: string;
57+
zoneName: string;
5758
record?: DnsRecordValue;
5859
}
5960

60-
export const HandleDnsRecord = ({ dnsProviderId, zoneId, record }: Props) => {
61+
export const HandleDnsRecord = ({
62+
dnsProviderId,
63+
zoneId,
64+
zoneName,
65+
record,
66+
}: Props) => {
6167
const utils = api.useUtils();
6268
const [isOpen, setIsOpen] = useState(false);
6369

@@ -102,11 +108,12 @@ export const HandleDnsRecord = ({ dnsProviderId, zoneId, record }: Props) => {
102108
const type = form.watch("type");
103109

104110
const onSubmit = async (data: DnsRecordForm) => {
111+
const name = data.name.trim() === "@" ? zoneName : data.name;
105112
const payload = {
106113
dnsProviderId,
107114
zoneId,
108115
type: data.type,
109-
name: data.name,
116+
name,
110117
content: data.content,
111118
ttl: data.ttl ? Number(data.ttl) : undefined,
112119
...(record && { recordId: record.id }),

‎apps/dokploy/components/dashboard/settings/dns/show-dns-provider-zones.tsx‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,10 @@ import { HandleDnsRecord } from "./handle-dns-record";
2424
interface ZoneRecordsProps {
2525
dnsProviderId: string;
2626
zoneId: string;
27+
zoneName: string;
2728
}
2829

29-
const ZoneRecords = ({ dnsProviderId, zoneId }: ZoneRecordsProps) => {
30+
const ZoneRecords = ({ dnsProviderId, zoneId, zoneName }: ZoneRecordsProps) => {
3031
const utils = api.useUtils();
3132
const { data, isLoading, isError, error } =
3233
api.dnsProvider.listRecords.useQuery({ dnsProviderId, zoneId });
@@ -71,6 +72,7 @@ const ZoneRecords = ({ dnsProviderId, zoneId }: ZoneRecordsProps) => {
7172
<HandleDnsRecord
7273
dnsProviderId={dnsProviderId}
7374
zoneId={zoneId}
75+
zoneName={zoneName}
7476
record={record}
7577
/>
7678
)}
@@ -112,7 +114,11 @@ const ZoneRecords = ({ dnsProviderId, zoneId }: ZoneRecordsProps) => {
112114
})}
113115
{canWrite && (
114116
<div className="pt-1">
115-
<HandleDnsRecord dnsProviderId={dnsProviderId} zoneId={zoneId} />
117+
<HandleDnsRecord
118+
dnsProviderId={dnsProviderId}
119+
zoneId={zoneId}
120+
zoneName={zoneName}
121+
/>
116122
</div>
117123
)}
118124
</div>
@@ -198,6 +204,7 @@ export const ShowDnsProviderZones = ({
198204
<ZoneRecords
199205
dnsProviderId={dnsProviderId}
200206
zoneId={zone.id}
207+
zoneName={zone.name}
201208
/>
202209
)}
203210
</div>

0 commit comments

Comments
 (0)