fix(api): don't undo domain verification on DNS re-check, fix theme lookup crash
- domains.ts: a proxied Cloudflare custom hostname's real CNAME target is never visible to a plain DNS lookup, so a re-verify always fails and was silently downgrading already-verified domains back to pending. Only a first-time check can now land on pending. - restaurants.ts: PUT /restaurants/:id/theme referenced an undeclared themeData variable (pre-existing tsc error on main, not introduced here) — added the missing themes-by-key lookup it depended on.
This commit is contained in:
@@ -179,7 +179,12 @@ export const domainsRoutes: FastifyPluginAsync = async (app) => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// If not verified, set/keep status as pending or failed
|
// A DNS CNAME lookup structurally cannot see the real target once the
|
||||||
|
// record is proxied (Cloudflare hides it behind its own edge IPs) — so a
|
||||||
|
// failed re-check here is inconclusive, not proof the domain broke.
|
||||||
|
// Never downgrade a domain that was already verified; only a first-time
|
||||||
|
// check is allowed to land on "pending".
|
||||||
|
if (domain.status !== "verified") {
|
||||||
await supabase
|
await supabase
|
||||||
.from("domains")
|
.from("domains")
|
||||||
.update({
|
.update({
|
||||||
@@ -187,10 +192,11 @@ export const domainsRoutes: FastifyPluginAsync = async (app) => {
|
|||||||
verified_at: null,
|
verified_at: null,
|
||||||
})
|
})
|
||||||
.eq("id", domainId);
|
.eq("id", domainId);
|
||||||
|
}
|
||||||
|
|
||||||
return reply.send({
|
return reply.send({
|
||||||
verified: false,
|
verified: domain.status === "verified",
|
||||||
domain: { ...domain, status: "pending", verified_at: null },
|
domain: domain.status === "verified" ? domain : { ...domain, status: "pending", verified_at: null },
|
||||||
message: `Doğrulanamadı: ${dnsErrorDetails}\n\nLütfen alan adı yönetim panelinizden (Cloudflare, GoDaddy, Natro vb.) ${domain.hostname} için CNAME kaydını ${expectedTarget} adresine yönlendirin.`,
|
message: `Doğrulanamadı: ${dnsErrorDetails}\n\nLütfen alan adı yönetim panelinizden (Cloudflare, GoDaddy, Natro vb.) ${domain.hostname} için CNAME kaydını ${expectedTarget} adresine yönlendirin.`,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -168,6 +168,8 @@ export const restaurantsRoutes: FastifyPluginAsync = async (app) => {
|
|||||||
classic: "Classic Bistro",
|
classic: "Classic Bistro",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const { data: themeData } = await supabase.from("themes").select("id").eq("key", themeKey).maybeSingle();
|
||||||
|
|
||||||
let themeId = themeData?.id;
|
let themeId = themeData?.id;
|
||||||
if (!themeId) {
|
if (!themeId) {
|
||||||
const { data: newTheme } = await supabase
|
const { data: newTheme } = await supabase
|
||||||
|
|||||||
Reference in New Issue
Block a user