fix: load .env before imports and improve dev startup

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-05-27 22:22:19 +08:00
parent 8c56dbc459
commit d20a2639b6
9 changed files with 359 additions and 22 deletions

13
server/load-env.ts Normal file
View File

@@ -0,0 +1,13 @@
import dotenv from "dotenv";
import fs from "node:fs";
import path from "node:path";
import { fileURLToPath } from "node:url";
const serverDir = path.dirname(fileURLToPath(import.meta.url));
const rootEnv = path.resolve(serverDir, "../.env");
if (fs.existsSync(rootEnv)) {
dotenv.config({ path: rootEnv });
} else {
dotenv.config();
}