diff --git a/src/lib/config/index.ts b/src/lib/config/index.ts index 483053811..a37b6e8e5 100644 --- a/src/lib/config/index.ts +++ b/src/lib/config/index.ts @@ -228,9 +228,24 @@ class ConfigManager { /* search section */ this.uiConfigSections.search.forEach((f) => { - if (f.env && !this.currentConfig.search[f.key]) { - this.currentConfig.search[f.key] = - process.env[f.env] ?? f.default ?? ''; + if (!f.env) return; + + const envValue = process.env[f.env]?.trim(); + if (envValue) { + if (f.key === 'searxngURL') { + try { + new URL(envValue); + } catch { + return; + } + } + + this.currentConfig.search[f.key] = envValue; + return; + } + + if (!this.currentConfig.search[f.key]) { + this.currentConfig.search[f.key] = f.default ?? ''; } });