diff --git a/apps/api/src/routes/domains.ts b/apps/api/src/routes/domains.ts index 27b90fb..e23ffb0 100644 --- a/apps/api/src/routes/domains.ts +++ b/apps/api/src/routes/domains.ts @@ -179,18 +179,24 @@ export const domainsRoutes: FastifyPluginAsync = async (app) => { }); } - // If not verified, set/keep status as pending or failed - await supabase - .from("domains") - .update({ - status: "pending", - verified_at: null, - }) - .eq("id", domainId); + // 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 + .from("domains") + .update({ + status: "pending", + verified_at: null, + }) + .eq("id", domainId); + } return reply.send({ - verified: false, - domain: { ...domain, status: "pending", verified_at: null }, + verified: domain.status === "verified", + 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.`, }); }); diff --git a/apps/api/src/routes/restaurants.ts b/apps/api/src/routes/restaurants.ts index cfb18cb..3e63395 100644 --- a/apps/api/src/routes/restaurants.ts +++ b/apps/api/src/routes/restaurants.ts @@ -168,6 +168,8 @@ export const restaurantsRoutes: FastifyPluginAsync = async (app) => { classic: "Classic Bistro", }; + const { data: themeData } = await supabase.from("themes").select("id").eq("key", themeKey).maybeSingle(); + let themeId = themeData?.id; if (!themeId) { const { data: newTheme } = await supabase