fix: validate LLM_API_URL format in getLlmUrl function
Browse files- lib/llm.ts +6 -1
lib/llm.ts
CHANGED
|
@@ -17,7 +17,12 @@ interface ChatCompletionResponse {
|
|
| 17 |
}
|
| 18 |
|
| 19 |
function getLlmUrl(): string {
|
| 20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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> {
|