fix: honor SEARXNG_API_URL for external SearXNG setups#1057
fix: honor SEARXNG_API_URL for external SearXNG setups#1057stablegenius49 wants to merge 2 commits intoItzCrazyKns:masterfrom
Conversation
|
Code Review - PR #1057 SummaryThis PR fixes an issue where SEARXNG_API_URL environment variable wasn't being honored in the search configuration. The change refactors the config loading logic to prioritize environment variables over existing config values. ✅ Strengths
|
|
Pushed a small follow-up to tighten the env override path:
Validation:
|
There was a problem hiding this comment.
1 issue found across 1 file (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="src/lib/config/index.ts">
<violation number="1" location="src/lib/config/index.ts:239">
P2: Invalid `SEARXNG_API_URL` is silently ignored, leaving stale persisted `search.searxngURL` active and re-saved.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| try { | ||
| new URL(envValue); | ||
| } catch { | ||
| return; |
There was a problem hiding this comment.
P2: Invalid SEARXNG_API_URL is silently ignored, leaving stale persisted search.searxngURL active and re-saved.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/lib/config/index.ts, line 239:
<comment>Invalid `SEARXNG_API_URL` is silently ignored, leaving stale persisted `search.searxngURL` active and re-saved.</comment>
<file context>
@@ -230,8 +230,16 @@ class ConfigManager {
+ try {
+ new URL(envValue);
+ } catch {
+ return;
+ }
+ }
</file context>
| return; | |
| this.currentConfig.search[f.key] = f.default ?? ''; | |
| return; |
Closes #954.
Summary
SEARXNG_API_URLwhen it is set, even ifdata/config.jsonalready contains an older SearXNG URLWhy
Containerized installs that switch from the bundled localhost SearXNG to an external instance can get stuck on the stale persisted URL, so restarts keep targeting
127.0.0.1:<port>instead of the address provided via env.Verification
data/config.jsonthat containedhttp://127.0.0.1:8080; after the change, settingSEARXNG_API_URL=http://searxng.example:8080correctly overrides it on startupSEARXNG_API_URLis unsetnpx eslint src/lib/config/index.tsnpx tsc --noEmitSummary by cubic
Honor
SEARXNG_API_URLon startup so external SearXNG instances override stale persisted URLs and containers stop targeting localhost after a switch. Ignore blank or invalid env values to avoid clobbering the config.SEARXNG_API_URLto override any persisted SearXNG URL.Written for commit 75c1cc8. Summary will update on new commits.