diff --git a/lib/permission-middleware.js b/lib/permission-middleware.js index 423c6e3..53e1cad 100644 --- a/lib/permission-middleware.js +++ b/lib/permission-middleware.js @@ -13,14 +13,11 @@ export async function getUserFromRequest(req) { if (!authHeader || !authHeader.startsWith('Bearer ')) { // For development, return user ID 1 if no token (should be removed in production) console.warn('⚠️ Development mode: Using fallback user authentication'); - console.warn('⚠️ No auth header found:', authHeader); return { userId: 1, email: 'admin@tcgvault.com', role: 'admin' }; } const token = authHeader.substring(7); - console.log('🔍 Attempting to verify token:', token.substring(0, 20) + '...'); const decoded = jwt.verify(token, JWT_SECRET); - console.log('✅ Token decoded successfully:', decoded); // Get user data from database const result = await sql` diff --git a/pages/collection/[identifier].js b/pages/collection/[identifier].js index e088526..af2f39d 100644 --- a/pages/collection/[identifier].js +++ b/pages/collection/[identifier].js @@ -64,7 +64,11 @@ export default function CollectionView() { const fetchCollectionData = async () => { try { - const response = await fetch(`/api/collections/${identifier}`); + const response = await fetch(`/api/collections/${identifier}`, { + headers: { + 'Authorization': `Bearer ${localStorage.getItem('auth_token')}` + } + }); if (response.ok) { const data = await response.json(); @@ -85,7 +89,11 @@ export default function CollectionView() { }); // Fetch collection cards - const cardsResponse = await fetch(`/api/collections/${identifier}/cards`); + const cardsResponse = await fetch(`/api/collections/${identifier}/cards`, { + headers: { + 'Authorization': `Bearer ${localStorage.getItem('auth_token')}` + } + }); if (cardsResponse.ok) { const cardsData = await cardsResponse.json(); setCards(cardsData.cards || []);