No description
Task: Fix provider baseUrl stripping endpoint suffixes before /models ## Problem When users entered a full endpoint URL as the provider base URL (e.g. `https://api.openai.com/v1/chat/completions` instead of `https://api.openai.com/v1`), the server would append `/models` to it, producing the invalid path `/v1/chat/completions/models` — resulting in HTTP 404 errors for model discovery, connection tests, and analysis. ## Changes ### `artifacts/api-server/src/lib/aiAnalysis.ts` - Added exported `normalizeBaseUrl(raw: string): string` helper that: - Strips trailing slashes - Strips known endpoint suffixes: `/chat/completions`, `/completions`, `/messages` - Strips trailing slashes again after suffix removal - Applied `normalizeBaseUrl` in `callOpenAiCompatible`, `callAnthropic`, and `listProviderModels` (replacing the previous bare `.replace(/\/$/, "")`) ### `artifacts/api-server/src/routes/providers.ts` - Imported `normalizeBaseUrl` from aiAnalysis - Applied normalization to `baseUrl` in the POST /providers (create) handler - Applied normalization to `baseUrl` in the PATCH /providers/:id (update) handler - This ensures the canonical normalized value is persisted from the start ### `artifacts/api-server/src/routes/providers.listModels.test.ts` - Added import of `normalizeBaseUrl` - Added a new `describe("normalizeBaseUrl")` block with 7 unit tests covering: all three suffix patterns, trailing slashes, clean URLs, combined suffix+slash, and non-matching partial suffixes ## Test results All 13 tests pass (6 existing + 7 new normalization unit tests). Replit-Task-Id: 9ab5c336-d54e-4bc3-8f01-0b7486365c4b |
||
|---|---|---|
| .agents/memory | ||
| artifacts | ||
| attached_assets | ||
| lib | ||
| scripts | ||
| .gitignore | ||
| .npmrc | ||
| .replit | ||
| .replitignore | ||
| package.json | ||
| pnpm-lock.yaml | ||
| pnpm-workspace.yaml | ||
| replit.md | ||
| tsconfig.base.json | ||
| tsconfig.json | ||