const http = require('http'); // 测试项目接口 function testProjectsAPI() { const options = { hostname: 'localhost', port: 5351, path: '/api/projects?page=1&limit=12&search=&status=', method: 'GET', headers: { 'Content-Type': 'application/json' } }; const req = http.request(options, (res) => { let data = ''; res.on('data', (chunk) => { data += chunk; }); res.on('end', () => { console.log('状态码:', res.statusCode); console.log('响应头:', res.headers); console.log('响应体:', data); if (res.statusCode === 500) { console.log('\n❌ 服务器内部错误'); try { const errorData = JSON.parse(data); console.log('错误信息:', errorData.message); if (errorData.error) { console.log('详细错误:', errorData.error); } } catch (e) { console.log('无法解析错误响应'); } } else if (res.statusCode === 200) { console.log('\n✅ 请求成功'); try { const responseData = JSON.parse(data); console.log('项目数量:', responseData.data?.projects?.length || 0); } catch (e) { console.log('无法解析成功响应'); } } }); }); req.on('error', (error) => { console.error('请求错误:', error.message); }); req.end(); } console.log('🚀 测试项目接口...'); testProjectsAPI();