60 lines
1.9 KiB
JavaScript
60 lines
1.9 KiB
JavaScript
#!/usr/bin/env node
|
|
|
|
/**
|
|
* 配置檢查工具
|
|
* 用於驗證環境變量配置是否正確
|
|
*/
|
|
|
|
console.log('🔍 檢查環境變量配置...\n');
|
|
|
|
// 檢查環境變量
|
|
const envVars = {
|
|
'NEXT_PUBLIC_APP_URL': process.env.NEXT_PUBLIC_APP_URL,
|
|
'NEXT_PUBLIC_APP_NAME': process.env.NEXT_PUBLIC_APP_NAME,
|
|
'DB_HOST': process.env.DB_HOST,
|
|
'DB_PORT': process.env.DB_PORT,
|
|
'DB_NAME': process.env.DB_NAME,
|
|
'DB_USER': process.env.DB_USER,
|
|
'DB_PASSWORD': process.env.DB_PASSWORD ? '***已設置***' : undefined,
|
|
'GEMINI_API_KEY': process.env.GEMINI_API_KEY ? '***已設置***' : undefined,
|
|
'GEMINI_MODEL': process.env.GEMINI_MODEL,
|
|
'GEMINI_MAX_TOKENS': process.env.GEMINI_MAX_TOKENS,
|
|
};
|
|
|
|
console.log('📋 當前環境變量:');
|
|
let hasErrors = false;
|
|
|
|
Object.entries(envVars).forEach(([key, value]) => {
|
|
const status = value ? '✅' : '❌';
|
|
const displayValue = value || '未設置';
|
|
console.log(` ${status} ${key}: ${displayValue}`);
|
|
if (!value && key !== 'GEMINI_MAX_TOKENS') {
|
|
hasErrors = true;
|
|
}
|
|
});
|
|
|
|
console.log('');
|
|
|
|
if (hasErrors) {
|
|
console.log('❌ 發現配置問題,請設置缺少的環境變量');
|
|
console.log('\n💡 建議的 .env.local 配置:');
|
|
} else {
|
|
console.log('✅ 所有必要的環境變量都已設置');
|
|
console.log('\n🔧 建議的 .env.local 配置:');
|
|
}
|
|
|
|
console.log('NEXT_PUBLIC_APP_URL=http://localhost:12024');
|
|
console.log('NEXT_PUBLIC_APP_NAME=AI 智能評審系統');
|
|
console.log('DB_HOST=mysql.theaken.com');
|
|
console.log('DB_PORT=33306');
|
|
console.log('DB_NAME=db_AI_scoring');
|
|
console.log('DB_USER=root');
|
|
console.log('DB_PASSWORD=zh6161168');
|
|
console.log('GEMINI_API_KEY=AIzaSyAN3pEJr_Vn2xkCidGZAq9eQqsMVvpj8g4');
|
|
console.log('GEMINI_MODEL=gemini-1.5-pro');
|
|
console.log('GEMINI_MAX_TOKENS=8192');
|
|
|
|
console.log('\n📝 使用說明:');
|
|
console.log('1. 複製 env.example 到 .env.local');
|
|
console.log('2. 根據需要修改配置');
|
|
console.log('3. 重啟開發服務器: npm run dev'); |