fix: change postinstall to prebuild for patch_appwrite.js and add monkey patches to appwrite clients

This commit is contained in:
Carlos (Almeira) 2026-07-09 23:15:56 -05:00
parent efd085ee5f
commit ade675e0d8
3 changed files with 25 additions and 1 deletions

View File

@ -8,7 +8,7 @@
"start": "next start",
"lint": "eslint",
"check-config": "node --env-file=.env.local check_config.js",
"postinstall": "node patch_appwrite.js"
"prebuild": "node patch_appwrite.js"
},
"dependencies": {
"@livekit/components-react": "^2.9.21",

View File

@ -1,6 +1,18 @@
import { Client, Account, Databases } from 'node-appwrite';
import { cookies } from 'next/headers';
// Patch console.warn to suppress Appwrite version mismatch warning
if (typeof console !== 'undefined' && !(console as any)._appwritePatchedServer) {
const originalWarn = console.warn;
console.warn = (...args) => {
if (args[0] && typeof args[0] === 'string' && args[0].includes('The current SDK is built for Appwrite')) {
return;
}
originalWarn(...args);
};
(console as any)._appwritePatchedServer = true;
}
const ENDPOINT = process.env.NEXT_PUBLIC_APPWRITE_ENDPOINT || 'https://appwrite.almeira.com.co/v1';
const PROJECT_ID = process.env.NEXT_PUBLIC_APPWRITE_PROJECT_ID || '69b84df5003bd8957c5c';
const COOKIE_NAME = `a_session_${PROJECT_ID.toLowerCase()}`;

View File

@ -1,5 +1,17 @@
import { Client, Databases, Storage, Query, Account } from 'appwrite';
// Patch console.warn to suppress Appwrite version mismatch warning
if (typeof console !== 'undefined' && !(console as any)._appwritePatchedClient) {
const originalWarn = console.warn;
console.warn = (...args) => {
if (args[0] && typeof args[0] === 'string' && args[0].includes('The current SDK is built for Appwrite')) {
return;
}
originalWarn(...args);
};
(console as any)._appwritePatchedClient = true;
}
const client = new Client();
export const endpoint = process.env.NEXT_PUBLIC_APPWRITE_ENDPOINT || 'https://appwrite.almeira.com.co/v1';