kmoney4600
01/12/2024, 1:54 AMjs
// /pages/api/players
import { firestore } from "../../lib/firebase.js"
import { collection, getDocs } from "firebase/firestore";
export default async function handler() {
const playerCollection = collection(firestore, 'players')
try {
const querySnapshot = await getDocs(playerCollection);
const players = querySnapshot.docs.map(doc => doc.data())
return Response.json(players)
}
catch(error) {
console.error("Error fetching players:", error);
return Response.error({ error: error.message });
}
}
export const runtime = 'edge';
Works locally and returns the players but on the deployed site I get the following
"logs": [
{
"message": [
"[2024-01-12T00:26:07.105Z] @firebase/firestore:",
"Firestore (10.7.1): Could not reach Cloud Firestore backend. Backend didn't respond within 10 seconds.\nThis typically indicates that your device does not have a healthy Internet connection at the moment. The client will operate in offline mode until it is able to successfully connect to the backend."
],
"level": "error",
"timestamp": 1705019167105
}
],
Account id: af8655034e4604c85f195db49950778e
Deployment id: 15bdd53b-16dc-4dc0-af06-5e9ec3e0fc11
Page: https://lack-leaderboards.pages.dev/kmoney4600
01/12/2024, 6:13 PM