From b0fdf220bc9af0eeb2a568fe012c8d34d9194d22 Mon Sep 17 00:00:00 2001 From: "Carlos (Almeira)" Date: Wed, 1 Jul 2026 19:54:04 -0500 Subject: [PATCH] Fix next/headers import and add debug info for requireAuth --- src/app/api/publications/route.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/app/api/publications/route.ts b/src/app/api/publications/route.ts index 8b6e8f2..20281b7 100644 --- a/src/app/api/publications/route.ts +++ b/src/app/api/publications/route.ts @@ -9,6 +9,7 @@ * 4. Returns standardized ApiResponse */ import { NextRequest, NextResponse } from 'next/server'; +import { cookies } from 'next/headers'; import { ID, Query } from 'node-appwrite'; import { createSessionClient, createAdminClient } from '@/lib/appwrite.server'; import { APPWRITE_ALMEIRA_CONFIG } from '@/lib/appwrite'; @@ -34,7 +35,6 @@ async function requireAuth() { try { // Si es modo bypass (admin-emergency), no podemos llamar a account.get() con la API Key - const { cookies } = require('next/headers'); const cookieStore = await cookies(); const PROJECT_ID = process.env.NEXT_PUBLIC_APPWRITE_PROJECT_ID || '69b84df5003bd8957c5c'; const sessionCookie = cookieStore.get(`a_session_${PROJECT_ID.toLowerCase()}`); @@ -54,9 +54,9 @@ async function requireAuth() { const user = await session.account.get(); return { user, session, error: null }; - } catch { + } catch (error: any) { return { user: null, error: NextResponse.json( - { success: false, error: 'Sesión inválida o expirada.' }, + { success: false, error: 'Sesión inválida o expirada. Debug: ' + (error?.message || error) }, { status: 401 } )}; }