fix: strip id/system fields before creating PB records

This commit is contained in:
Dave 2026-08-14 21:06:21 +02:00
parent c1b98a6eca
commit 2d402c0482

View file

@ -86,11 +86,13 @@ export async function createRecord<T extends PBRecord>(
collection: string,
fields: Record<string, unknown>,
): Promise<T> {
// Strip id/system fields — let PB auto-generate them.
const { id: _id, created: _c, updated: _u, ...safeFields } = fields;
const url = `${BASE_URL}/api/collections/${collection}/records`;
const res = await fetch(url, {
method: "POST",
headers: { Authorization: TOKEN as string, "Content-Type": "application/json" },
body: JSON.stringify(fields),
body: JSON.stringify(safeFields),
cache: "no-store",
});
if (!res.ok) {