mirror of
https://github.com/andwati/dokploy.git
synced 2026-11-18 01:45:17 +00:00
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:
@@ -54,10 +54,16 @@ interface DnsRecordValue {
|
|||||||
interface Props {
|
interface Props {
|
||||||
dnsProviderId: string;
|
dnsProviderId: string;
|
||||||
zoneId: string;
|
zoneId: string;
|
||||||
|
zoneName: string;
|
||||||
record?: DnsRecordValue;
|
record?: DnsRecordValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const HandleDnsRecord = ({ dnsProviderId, zoneId, record }: Props) => {
|
export const HandleDnsRecord = ({
|
||||||
|
dnsProviderId,
|
||||||
|
zoneId,
|
||||||
|
zoneName,
|
||||||
|
record,
|
||||||
|
}: Props) => {
|
||||||
const utils = api.useUtils();
|
const utils = api.useUtils();
|
||||||
const [isOpen, setIsOpen] = useState(false);
|
const [isOpen, setIsOpen] = useState(false);
|
||||||
|
|
||||||
@@ -102,11 +108,12 @@ export const HandleDnsRecord = ({ dnsProviderId, zoneId, record }: Props) => {
|
|||||||
const type = form.watch("type");
|
const type = form.watch("type");
|
||||||
|
|
||||||
const onSubmit = async (data: DnsRecordForm) => {
|
const onSubmit = async (data: DnsRecordForm) => {
|
||||||
|
const name = data.name.trim() === "@" ? zoneName : data.name;
|
||||||
const payload = {
|
const payload = {
|
||||||
dnsProviderId,
|
dnsProviderId,
|
||||||
zoneId,
|
zoneId,
|
||||||
type: data.type,
|
type: data.type,
|
||||||
name: data.name,
|
name,
|
||||||
content: data.content,
|
content: data.content,
|
||||||
ttl: data.ttl ? Number(data.ttl) : undefined,
|
ttl: data.ttl ? Number(data.ttl) : undefined,
|
||||||
...(record && { recordId: record.id }),
|
...(record && { recordId: record.id }),
|
||||||
|
|||||||
@@ -24,9 +24,10 @@ import { HandleDnsRecord } from "./handle-dns-record";
|
|||||||
interface ZoneRecordsProps {
|
interface ZoneRecordsProps {
|
||||||
dnsProviderId: string;
|
dnsProviderId: string;
|
||||||
zoneId: string;
|
zoneId: string;
|
||||||
|
zoneName: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ZoneRecords = ({ dnsProviderId, zoneId }: ZoneRecordsProps) => {
|
const ZoneRecords = ({ dnsProviderId, zoneId, zoneName }: ZoneRecordsProps) => {
|
||||||
const utils = api.useUtils();
|
const utils = api.useUtils();
|
||||||
const { data, isLoading, isError, error } =
|
const { data, isLoading, isError, error } =
|
||||||
api.dnsProvider.listRecords.useQuery({ dnsProviderId, zoneId });
|
api.dnsProvider.listRecords.useQuery({ dnsProviderId, zoneId });
|
||||||
@@ -71,6 +72,7 @@ const ZoneRecords = ({ dnsProviderId, zoneId }: ZoneRecordsProps) => {
|
|||||||
<HandleDnsRecord
|
<HandleDnsRecord
|
||||||
dnsProviderId={dnsProviderId}
|
dnsProviderId={dnsProviderId}
|
||||||
zoneId={zoneId}
|
zoneId={zoneId}
|
||||||
|
zoneName={zoneName}
|
||||||
record={record}
|
record={record}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
@@ -112,7 +114,11 @@ const ZoneRecords = ({ dnsProviderId, zoneId }: ZoneRecordsProps) => {
|
|||||||
})}
|
})}
|
||||||
{canWrite && (
|
{canWrite && (
|
||||||
<div className="pt-1">
|
<div className="pt-1">
|
||||||
<HandleDnsRecord dnsProviderId={dnsProviderId} zoneId={zoneId} />
|
<HandleDnsRecord
|
||||||
|
dnsProviderId={dnsProviderId}
|
||||||
|
zoneId={zoneId}
|
||||||
|
zoneName={zoneName}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
@@ -198,6 +204,7 @@ export const ShowDnsProviderZones = ({
|
|||||||
<ZoneRecords
|
<ZoneRecords
|
||||||
dnsProviderId={dnsProviderId}
|
dnsProviderId={dnsProviderId}
|
||||||
zoneId={zone.id}
|
zoneId={zone.id}
|
||||||
|
zoneName={zone.name}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user