fix: load .env before imports and improve dev startup
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
13
server/load-env.ts
Normal file
13
server/load-env.ts
Normal 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();
|
||||
}
|
||||
Reference in New Issue
Block a user