Skip to content

Commit 1b2d1d9

Browse files
committed
🚨 CRITICAL FIX: Firebase Admin undefined error in token allocations API
ISSUE: TypeError: Cannot read properties of undefined (reading 'collection') ROOT CAUSE: Incorrect destructuring of getFirebaseAdmin() return value FIXES: ✅ Fixed Firebase Admin usage in token allocations route ✅ Added null check for admin instance ✅ Changed from {adminDb} destructuring to direct admin.firestore() call This was blocking page loads for users with token allocations.
1 parent 605299a commit 1b2d1d9

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

‎app/api/tokens/allocations/route.ts‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,11 @@ export async function GET(request: NextRequest) {
110110
pageAllocations.map(async (allocation) => {
111111
try {
112112
// Get page metadata using direct Firebase call
113-
const { adminDb } = getFirebaseAdmin();
114-
const pageDoc = await adminDb.collection(getCollectionName('pages')).doc(allocation.resourceId).get();
113+
const admin = getFirebaseAdmin();
114+
if (!admin) {
115+
throw new Error('Firebase Admin not initialized');
116+
}
117+
const pageDoc = await admin.firestore().collection(getCollectionName('pages')).doc(allocation.resourceId).get();
115118
const pageData = pageDoc.exists ? pageDoc.data() : null;
116119

117120
if (!pageData) {

0 commit comments

Comments
 (0)