const axios = require('axios'); async function testAdminPhotoEndpoint() { try { // First login console.log('1. Logging in as admin...'); const loginResponse = await axios.post('http://localhost:3000/api/admin/auth/login', { username: 'admin', password: 'admin123' }); const token = loginResponse.data.token; console.log('✓ Login successful, got token'); // Test thumbnail endpoint console.log('\n2. Testing thumbnail endpoint for photo 1688...'); try { const thumbResponse = await axios.get('http://localhost:3000/api/admin/events/12/thumbnail/1688', { headers: { Authorization: `Bearer ${token}` }, responseType: 'arraybuffer' }); console.log('✓ Thumbnail request successful'); console.log(' Response headers:', thumbResponse.headers); console.log(' Data size:', thumbResponse.data.length, 'bytes'); } catch (error) { console.error('✗ Thumbnail request failed:', error.response?.status, error.response?.data?.toString()); } // Test from frontend proxy port console.log('\n3. Testing through nginx proxy (port 3001)...'); try { const proxyResponse = await axios.get('http://localhost:3001/api/admin/events/12/thumbnail/1688', { headers: { Authorization: `Bearer ${token}`, Origin: 'http://localhost:3005' }, responseType: 'arraybuffer' }); console.log('✓ Proxy request successful'); console.log(' Response headers:', proxyResponse.headers); console.log(' Data size:', proxyResponse.data.length, 'bytes'); } catch (error) { console.error('✗ Proxy request failed:', error.response?.status, error.response?.data?.toString()); } } catch (error) { console.error('Error:', error.message); } } testAdminPhotoEndpoint();