备份:修复前完整项目快照 2026-04-19
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
const http = require('http');
|
||||
|
||||
console.log('测试auth模块登录接口...');
|
||||
|
||||
const postData = JSON.stringify({
|
||||
username: 'admin',
|
||||
password: 'X123c321@'
|
||||
});
|
||||
|
||||
const options = {
|
||||
hostname: 'localhost',
|
||||
port: 3002,
|
||||
path: '/api/auth/login',
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Content-Length': Buffer.byteLength(postData)
|
||||
}
|
||||
};
|
||||
|
||||
console.log(`发送请求到: ${options.method} http://${options.hostname}:${options.port}${options.path}`);
|
||||
|
||||
const req = http.request(options, (res) => {
|
||||
console.log(`状态码: ${res.statusCode}`);
|
||||
console.log(`响应头: ${JSON.stringify(res.headers)}`);
|
||||
|
||||
let data = '';
|
||||
res.setEncoding('utf8');
|
||||
res.on('data', (chunk) => {
|
||||
data += chunk;
|
||||
});
|
||||
res.on('end', () => {
|
||||
console.log('\n响应体:');
|
||||
try {
|
||||
const parsed = JSON.parse(data);
|
||||
console.log(JSON.stringify(parsed, null, 2));
|
||||
|
||||
if (res.statusCode === 200 && parsed.success && parsed.data && parsed.data.token) {
|
||||
console.log('\n✅ auth模块迁移成功!');
|
||||
console.log(`获取到token: ${parsed.data.token.substring(0, 30)}...`);
|
||||
} else {
|
||||
console.log('\n❌ auth模块迁移失败');
|
||||
console.log('响应不符合预期');
|
||||
process.exit(1);
|
||||
}
|
||||
} catch (e) {
|
||||
console.log('解析响应失败:', e.message);
|
||||
console.log('原始响应:', data);
|
||||
process.exit(1);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
req.on('error', (e) => {
|
||||
console.error(`请求失败: ${e.message}`);
|
||||
process.exit(1);
|
||||
});
|
||||
|
||||
req.write(postData);
|
||||
req.end();
|
||||
Reference in New Issue
Block a user