fix: honor SESSION_SECRET_FILE in dashboard warning check #222
This commit is contained in:
@@ -2,6 +2,7 @@ import { readFile, writeFile, mkdir, rename } from 'node:fs/promises';
|
||||
import { existsSync } from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import { logger } from '@/lib/logger';
|
||||
import { readFileEnv } from '@/lib/read-file-env';
|
||||
import { CONFIG_ENV_MAP, DEFAULT_POLICY, DEFAULT_THEME_POLICY, type SettingsPolicy } from './types';
|
||||
|
||||
function getAdminDir(): string {
|
||||
@@ -64,6 +65,12 @@ class ConfigManager {
|
||||
if (envVal !== undefined) {
|
||||
return parseEnvValue(envVal, mapping.type) as T;
|
||||
}
|
||||
if (mapping.fileEnvVar) {
|
||||
const fileVal = readFileEnv(process.env[mapping.fileEnvVar]);
|
||||
if (fileVal !== null) {
|
||||
return parseEnvValue(fileVal, mapping.type) as T;
|
||||
}
|
||||
}
|
||||
if (defaultValue !== undefined) return defaultValue;
|
||||
return mapping.defaultValue as T;
|
||||
}
|
||||
@@ -94,9 +101,16 @@ class ConfigManager {
|
||||
const envVal = process.env[mapping.envVar];
|
||||
if (envVal !== undefined) {
|
||||
result[key] = { value: parseEnvValue(envVal, mapping.type), source: 'env' };
|
||||
} else {
|
||||
result[key] = { value: mapping.defaultValue, source: 'default' };
|
||||
continue;
|
||||
}
|
||||
if (mapping.fileEnvVar) {
|
||||
const fileVal = readFileEnv(process.env[mapping.fileEnvVar]);
|
||||
if (fileVal !== null) {
|
||||
result[key] = { value: parseEnvValue(fileVal, mapping.type), source: 'env' };
|
||||
continue;
|
||||
}
|
||||
}
|
||||
result[key] = { value: mapping.defaultValue, source: 'default' };
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
||||
Reference in New Issue
Block a user