Fix saveLesson: sanitize content JSON to prevent RSC proxy error
React treats TipTap's editor.getJSON() output as a non-plain object when passed through Server Action serialization, causing isDecimal() inside Prisma's query builder to receive a temporary client reference proxy and throw ERROR 1213974697. JSON.parse(JSON.stringify()) strips the prototype chain and any non-enumerable properties, ensuring Prisma receives a clean plain object. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -22,7 +22,6 @@ export async function saveLesson(
|
|||||||
}
|
}
|
||||||
) {
|
) {
|
||||||
await requireAdmin();
|
await requireAdmin();
|
||||||
try {
|
|
||||||
await prisma.lesson.update({
|
await prisma.lesson.update({
|
||||||
where: { id: lessonId },
|
where: { id: lessonId },
|
||||||
data: {
|
data: {
|
||||||
@@ -32,10 +31,6 @@ export async function saveLesson(
|
|||||||
published: data.published,
|
published: data.published,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
} catch (err) {
|
|
||||||
console.error("[saveLesson] full error:", err);
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
revalidatePath(`/admin/courses/${courseId}/modules/${moduleId}`);
|
revalidatePath(`/admin/courses/${courseId}/modules/${moduleId}`);
|
||||||
revalidatePath(`/admin/courses/${courseId}/modules/${moduleId}/lessons/${lessonId}`);
|
revalidatePath(`/admin/courses/${courseId}/modules/${moduleId}/lessons/${lessonId}`);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user