22 lines
818 B
JavaScript
22 lines
818 B
JavaScript
const fs = require('fs');
|
|
const content = fs.readFileSync('middleware/auth.js', 'utf8');
|
|
|
|
// 修复JWT_SECRET,使其与utils/auth.js中的一致
|
|
const fixedContent = content
|
|
.replace(
|
|
"const JWT_SECRET = process.env.JWT_SECRET || 'your-secret-key-change-in-production';",
|
|
"const JWT_SECRET = process.env.JWT_SECRET || 'your-jwt-secret-change-in-production';"
|
|
);
|
|
|
|
// 写入修复后的文件
|
|
fs.writeFileSync('middleware/auth.js', fixedContent);
|
|
console.log('✅ 已修复middleware/auth.js中的JWT_SECRET');
|
|
|
|
// 验证修复
|
|
const fixedFileContent = fs.readFileSync('middleware/auth.js', 'utf8');
|
|
if (fixedFileContent.includes("'your-jwt-secret-change-in-production'")) {
|
|
console.log('✅ JWT_SECRET修复验证成功');
|
|
} else {
|
|
console.log('❌ JWT_SECRET修复验证失败');
|
|
process.exit(1);
|
|
} |