const fetch = require('node-fetch'); async function testEnvLogin() { try { console.log('Testing admin login with .env credentials...'); console.log('Username: admin, Password: 0000'); const loginRes = await fetch('http://localhost:4000/api/admin/login', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ username: 'admin', password: '0000' }) }); console.log('Response status:', loginRes.status); const data = await loginRes.json(); console.log('Response data:', data); if (loginRes.ok) { console.log('✅ Login successful! Token received'); // Test the token by calling a protected endpoint console.log('Testing protected endpoint...'); const teamsRes = await fetch('http://localhost:4000/api/teams', { headers: { 'Authorization': `Bearer ${data.token}` } }); if (teamsRes.ok) { const teams = await teamsRes.json(); console.log(`✅ Token works! Found ${teams.length} teams`); } else { console.log('❌ Token validation failed'); } } else { console.log('❌ Login failed:', data.error); } } catch (err) { console.error('Error:', err.message); } } testEnvLogin();