diff --git a/src/lib/appwrite.server.ts b/src/lib/appwrite.server.ts index 06af964..ab30e85 100644 --- a/src/lib/appwrite.server.ts +++ b/src/lib/appwrite.server.ts @@ -10,6 +10,19 @@ if (typeof console !== 'undefined' && !(console as any)._appwritePatchedServer) } originalWarn(...args); }; + + // Monkey-patch Client.prototype.call to always return plain objects + const originalCall = Client.prototype.call; + if (originalCall) { + Client.prototype.call = async function (this: any, ...args: any[]) { + const res = await originalCall.apply(this, args); + if (res && typeof res === 'object') { + return JSON.parse(JSON.stringify(res)); + } + return res; + }; + } + (console as any)._appwritePatchedServer = true; } diff --git a/src/lib/appwrite.ts b/src/lib/appwrite.ts index 989bc94..a3d4551 100644 --- a/src/lib/appwrite.ts +++ b/src/lib/appwrite.ts @@ -9,6 +9,19 @@ if (typeof console !== 'undefined' && !(console as any)._appwritePatchedClient) } originalWarn(...args); }; + + // Monkey-patch Client.prototype.call to always return plain objects + const originalCall = Client.prototype.call; + if (originalCall) { + Client.prototype.call = async function (this: any, ...args: any[]) { + const res = await originalCall.apply(this, args); + if (res && typeof res === 'object') { + return JSON.parse(JSON.stringify(res)); + } + return res; + }; + } + (console as any)._appwritePatchedClient = true; }