v0.3.12: 统一环境变量管理 + 去重

- CHROMIUM_PATH 从3处散落移到 config/index.ts 统一管理
- startup-validator 移除冗余 CORS_ORIGIN 检查 (main.ts 已处理)
- docker run 补充 JWT_SECRET/ADMIN_PASSWORD/COOKIE_ENCRYPTION_KEY
- 云盘常量统一到 cloud-constants.ts (图标/标签/颜色)
This commit is contained in:
2026-05-17 14:13:51 +08:00
parent 77a8c5126f
commit 1e0d408dd2
7 changed files with 10 additions and 15 deletions

View File

@@ -1 +1 @@
0.3.11 0.3.12

View File

@@ -1 +1 @@
0.3.11 0.3.12

View File

@@ -37,7 +37,8 @@ interface ShareDetail {
// Constants // Constants
// ═══════════════════════════════════ // ═══════════════════════════════════
const API_HOST = "https://pan.baidu.com"; const API_HOST = "https://pan.baidu.com";
const CHROMIUM_PATH = process.env.CHROMIUM_PATH || "/usr/bin/chromium-browser"; import config from '../../config';
const CHROMIUM_PATH = config.chromiumPath;
const APP_ID_WEB = "38824127"; // Web app ID from BaiduPanFilesTransfers const APP_ID_WEB = "38824127"; // Web app ID from BaiduPanFilesTransfers
// HTTP headers matching BaiduPanFilesTransfers // HTTP headers matching BaiduPanFilesTransfers

View File

@@ -19,7 +19,8 @@ const SESSIONS = new Map<string, QrSession>();
const SESSION_TTL = 5 * 60 * 1000; // 5 minutes const SESSION_TTL = 5 * 60 * 1000; // 5 minutes
const COOKIE_CHECK_INTERVAL = 1500; // 1.5s between cookie checks const COOKIE_CHECK_INTERVAL = 1500; // 1.5s between cookie checks
const CHROMIUM_PATH = process.env.CHROMIUM_PATH || '/usr/bin/chromium-browser'; import config from '../config';
const CHROMIUM_PATH = config.chromiumPath;
// Clean up old sessions periodically // Clean up old sessions periodically
setInterval(() => { setInterval(() => {

View File

@@ -14,6 +14,7 @@ export interface Config {
cacheTtlValid: number; cacheTtlValid: number;
cacheTtlInvalid: number; cacheTtlInvalid: number;
}; };
chromiumPath: string;
dbPath: string; dbPath: string;
} }
@@ -33,6 +34,7 @@ const config: Config = {
cacheTtlValid: parseInt(process.env.CACHE_TTL_VALID || '14400', 10), // 4小时 cacheTtlValid: parseInt(process.env.CACHE_TTL_VALID || '14400', 10), // 4小时
cacheTtlInvalid: parseInt(process.env.CACHE_TTL_INVALID || '3600', 10), // 1小时 cacheTtlInvalid: parseInt(process.env.CACHE_TTL_INVALID || '3600', 10), // 1小时
}, },
chromiumPath: process.env.CHROMIUM_PATH || "/usr/bin/chromium-browser",
dbPath: process.env.DB_PATH || './data/cloudsearch.db', dbPath: process.env.DB_PATH || './data/cloudsearch.db',
}; };

View File

@@ -51,16 +51,6 @@ export function validateConfig(): ValidationError[] {
}); });
} }
// ─── CORS ───
const corsOrigin = process.env.CORS_ORIGIN || '';
if (isProd && (!corsOrigin || corsOrigin === 'https://your-production-domain.com')) {
errors.push({
key: 'CORS_ORIGIN',
message: '生产环境未配置真实的 CORS_ORIGIN临时允许所有来源请求',
severity: 'warn',
});
}
// ─── Port conflict check (best-effort) ─── // ─── Port conflict check (best-effort) ───
if (config.port < 1024 && (process as any).getuid?.() !== 0) { if (config.port < 1024 && (process as any).getuid?.() !== 0) {
errors.push({ errors.push({

View File

@@ -19,7 +19,8 @@ const SESSIONS = new Map<string, QrSession>();
const SESSION_TTL = 5 * 60 * 1000; // 5 minutes const SESSION_TTL = 5 * 60 * 1000; // 5 minutes
const COOKIE_CHECK_INTERVAL = 1500; // 1.5s between cookie checks const COOKIE_CHECK_INTERVAL = 1500; // 1.5s between cookie checks
const CHROMIUM_PATH = process.env.CHROMIUM_PATH || '/usr/bin/chromium-browser'; import config from '../config';
const CHROMIUM_PATH = config.chromiumPath;
// Clean up old sessions periodically // Clean up old sessions periodically
setInterval(() => { setInterval(() => {