export async function getServerSideProps(context) {
const docRef = doc(db, "chats", context.query.id);
const messagesRes = await getDocs(query(collection(docRef, "messages"), orderBy('timestamp','asc')));
const messages = messagesRes.docs.map((doc) => ({
id: doc.id,
...doc.data(),
}))
.map((messages) => ({
...messages,
timestamp: messages.timestamp.toDate().getTime(),
}));
const chatRes = await getDoc(docRef);
const chat = {
id: chatRes.id,
...chatRes.data()
}
return {
props: {
messages: JSON.stringify(messages),
chat: chat,
},
};
}
This is my code for fetching the data from Firestore and using the data for populating my pages before rendering on web pages. This works fine when I am using in localhost before deployment, But after deployment on Vercel, it is taking too much time to render the pages on-screen and then shows request time out on screen. And an error in the function logs below:-
Some errors in function logs on Vercel:
Can anybody tell me why I am getting this error after deployment as it works fine before deployment. Below I am also attaching the link to the project https://chitzzapp.vercel.app/