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:
@@ -10,9 +10,16 @@ export async function GET(request: NextRequest) {
|
||||
return NextResponse.json({ error: "key is required" }, { status: 400 });
|
||||
}
|
||||
|
||||
const translation = await getContentByKey({ key, locale });
|
||||
if (!translation) return NextResponse.json({ content: null });
|
||||
|
||||
return NextResponse.json({ content: translation });
|
||||
try {
|
||||
const translation = await getContentByKey({ key, locale });
|
||||
if (!translation) return NextResponse.json({ content: null });
|
||||
return NextResponse.json({ content: translation });
|
||||
} catch (error) {
|
||||
// If DB isn't migrated/available, fail soft so the UI can fall back to next-intl strings.
|
||||
if (process.env.NODE_ENV === "development") {
|
||||
console.warn("Content API failed; returning null content:", error);
|
||||
}
|
||||
return NextResponse.json({ content: null });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user