修复打包后读取不到.env文件,编写打包脚本

This commit is contained in:
pingchuan
2025-06-09 14:48:58 +08:00
parent 582aa8fa4d
commit 13fb6ce79f
73 changed files with 26798 additions and 81968 deletions
+14 -7
View File
@@ -1,8 +1,14 @@
import { CHAT_CONFIG } from '../config/chat';
// 获取环境变量的服务端函数
const getServerEnvVar = (name: string, defaultValue: string = '') => {
return process.env[name] || defaultValue;
const value = process.env[name] || defaultValue;
// console.log(`🌐 [DifyClient] 读取环境变量 ${name}:`, {
// hasValue: !!process.env[name],
// value: process.env[name] ? `${process.env[name].substring(0, 20)}...` : 'undefined',
// usingDefault: !process.env[name]
// });
return value;
};
// Dify API 客户端配置
@@ -17,11 +23,12 @@ const DIFY_CONFIG = {
})(),
};
// console.log('🔧 Dify Client Config:', {
// apiUrl: DIFY_CONFIG.API_URL,
// appId: DIFY_CONFIG.APP_ID,
// hasApiKey: !!DIFY_CONFIG.API_KEY
// });
console.log('🔧 Dify Client Config:', {
apiUrl: DIFY_CONFIG.API_URL,
appId: DIFY_CONFIG.APP_ID,
hasApiKey: !!DIFY_CONFIG.API_KEY,
configComplete: !!(DIFY_CONFIG.API_URL && DIFY_CONFIG.APP_ID && DIFY_CONFIG.API_KEY)
});
// 基础请求函数
const difyFetch = async (endpoint: string, options: RequestInit = {}) => {