fix(consent): avoid banner flashing on reload

Initialize consent state from cookie synchronously so the banner only shows when no choice was made.

fix(api): fail-soft when DB schema missing

Return null/empty content for CMS endpoints when migrations are not applied instead of crashing with Prisma P2021/P2022.

fix(n8n): parse status response defensively

Handle empty/invalid JSON bodies from n8n to prevent activity feed from getting stuck.

Co-authored-by: dennis <dennis@konkol.net>
This commit is contained in:
Cursor Agent
2026-01-14 21:47:31 +00:00
parent 73ed89c15a
commit fbce838d3f
4 changed files with 59 additions and 30 deletions

View File

@@ -1,5 +1,6 @@
import { prisma } from "@/lib/prisma";
import type { Prisma } from "@prisma/client";
import { PrismaClientKnownRequestError } from "@prisma/client/runtime/library";
export async function getSiteSettings() {
return prisma.siteSettings.findUnique({ where: { id: 1 } });
@@ -7,29 +8,38 @@ export async function getSiteSettings() {
export async function getContentByKey(opts: { key: string; locale: string }) {
const { key, locale } = opts;
const page = await prisma.contentPage.findUnique({
where: { key },
include: {
translations: {
where: { locale },
take: 1,
try {
const page = await prisma.contentPage.findUnique({
where: { key },
include: {
translations: {
where: { locale },
take: 1,
},
},
},
});
});
if (page?.translations?.[0]) return page.translations[0];
if (page?.translations?.[0]) return page.translations[0];
const settings = await getSiteSettings();
const fallbackLocale = settings?.defaultLocale || "en";
const settings = await getSiteSettings();
const fallbackLocale = settings?.defaultLocale || "en";
const fallback = await prisma.contentPageTranslation.findFirst({
where: {
page: { key },
locale: fallbackLocale,
},
});
const fallback = await prisma.contentPageTranslation.findFirst({
where: {
page: { key },
locale: fallbackLocale,
},
});
return fallback;
return fallback;
} catch (error) {
// If migrations haven't been applied yet, don't crash the app.
// Let callers fall back to static translations.
if (error instanceof PrismaClientKnownRequestError && (error.code === "P2021" || error.code === "P2022")) {
return null;
}
throw error;
}
}
export async function upsertContentByKey(opts: {