fix(server): read the .env file on time (#12051)

This commit is contained in:
congzhou09
2025-04-29 15:48:17 +08:00
committed by GitHub
parent 83670ab335
commit f5f7cbb105
2 changed files with 8 additions and 2 deletions

View File

@@ -132,4 +132,8 @@ export class Env implements AppEnv {
}
}
globalThis.env = new Env();
export const createGlobalEnv = () => {
if (!globalThis.env) {
globalThis.env = new Env();
}
};

View File

@@ -1,5 +1,4 @@
import 'reflect-metadata';
import './env';
import { existsSync, readFileSync } from 'node:fs';
import { homedir } from 'node:os';
@@ -7,6 +6,8 @@ import { join } from 'node:path';
import { config } from 'dotenv';
import { createGlobalEnv } from './env';
const CUSTOM_CONFIG_PATH = `${homedir()}/.affine/config`;
function loadPrivateKey() {
@@ -37,3 +38,4 @@ function load() {
}
load();
createGlobalEnv();