Two of my projects are blocked when using functions
Code :
import { Client, Account ,Databases} from 'node-appwrite';
// This Appwrite function will be executed every time your function is triggered export default async ({ req, res, log, error }) => { if (req.method === 'OPTIONS') { return res.send('', 204, { 'Access-Control-Allow-Origin': '*', 'Access-Control-Allow-Methods': 'GET, POST, OPTIONS', 'Access-Control-Allow-Headers': 'Content-Type, Authorization, X-Appwrite-Key' }); } // Initialize the Appwrite client const client = new Client() .setEndpoint("https://6799b7db75f3f1251f5f.appwrite.global/v1") .setProject("6798f12500186de1e61d") .setKey(process.env.API_KEY);
// Initialize the Databases service const databases = new Databases(client);
const databaseId = "6798f1b2001d31742ec7"; const collectionId = "6798f1b9001f01d4c0c3";
try { // Fetch all documents from the specified collection const documentList = await databases.listDocuments(databaseId, collectionId);
return res.json({
success: true,
documents: documentList.documents,
}, 200, {
'Access-Control-Allow-Origin': '*',
});
} catch (err) {
// Return the error with appropriate CORS headers
return res.json({
success: false,
error: err.message,
}, 500, {
'Access-Control-Allow-Origin': '*',
});
} };
Recommended threads
- Functions in cloud console not works
please advise as all of my runing functions on Appwrite console was working before , but now it give this error [Invalid `headers` param: Value must be a valid...
- Cannot migrate from Supabase
Hi, I was trying to migrate from Supabase to the Appwrite database. My database had around 190K columns. I tried it twice. Both times, after 2 days, the proce...
- Production down - createExecution return...
Hey, Since 1.9.6 rollout in fra (~17:00 UTC, 14 Aug), POST /v1/functions/{functionId}/executions returns a 400 whenever the body includes an empty headers ob...