kjbytes commited on
Commit
deb9451
·
1 Parent(s): 41904c2

fix: validate LLM_API_URL format in getLlmUrl function

Browse files
Files changed (1) hide show
  1. lib/llm.ts +6 -1
lib/llm.ts CHANGED
@@ -17,7 +17,12 @@ interface ChatCompletionResponse {
17
  }
18
 
19
  function getLlmUrl(): string {
20
- return process.env.LLM_API_URL || DEFAULT_LLM_URL;
 
 
 
 
 
21
  }
22
 
23
  function buildHeaders(): Record<string, string> {
 
17
  }
18
 
19
  function getLlmUrl(): string {
20
+ const url = process.env.LLM_API_URL;
21
+ // ponytail: a key pasted into LLM_API_URL fails deep inside fetch — say so here instead
22
+ if (url && !/^https?:\/\//.test(url)) {
23
+ throw new Error(`LLM_API_URL is not a URL: ${url.slice(0, 12)}...`);
24
+ }
25
+ return url || DEFAULT_LLM_URL;
26
  }
27
 
28
  function buildHeaders(): Record<string, string> {