Skip to content

Commit ea1c6fc

Browse files
committed
fix(dns): fallback to data fields comparison for cloudflare structured SRV/CAA records
1 parent df0986b commit ea1c6fc

1 file changed

Lines changed: 20 additions & 10 deletions

File tree

‎packages/server/src/utils/dns/cloudflare.ts‎

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -169,23 +169,33 @@ export const cloudflareClient: DnsClient<CloudflareConfig> = {
169169
};
170170

171171
const existing = await cfFetch<
172-
{ id: string; type: string; content: string; priority?: number }[]
172+
{
173+
id: string;
174+
type: string;
175+
content: string;
176+
priority?: number;
177+
data?: Record<string, unknown>;
178+
}[]
173179
>(
174180
config,
175181
`/zones/${record.zoneId}/dns_records?type=${record.type}&name=${encodeURIComponent(record.name)}`,
176182
);
177183

178184
const built = buildValue(record);
179-
const normalizedRecord = {
180-
type: record.type,
181-
content: built.content ?? record.content.trim(),
182-
priority: built.priority,
183-
};
184-
const expectedContent = inlinePriority(normalizedRecord);
185185

186-
const existingRecord = existing.find(
187-
(r) => inlinePriority(r) === expectedContent,
188-
);
186+
const existingRecord = existing.find((r) => {
187+
if (built.data) {
188+
return Object.entries(built.data).every(
189+
([k, v]) => r.data && r.data[k] === v,
190+
);
191+
}
192+
const normalizedRecord = {
193+
type: record.type,
194+
content: built.content ?? record.content.trim(),
195+
priority: built.priority,
196+
};
197+
return inlinePriority(r) === inlinePriority(normalizedRecord);
198+
});
189199
if (existingRecord) {
190200
const updated = await cfFetch<{ id: string }>(
191201
config,

0 commit comments

Comments
 (0)