Skip to content

Proxy: tolerate trailing /v1 in lm_proxy_url #45

Closed

Description

@diskerror

Problem

`lm_proxy_url` is documented/felt to be an OpenAI-style base URL (`http://host:port/v1\`), but the proxy code prepends `/v1/*` itself. When users follow the `/v1` convention, URLs become `http://host:port/v1/v1/models\` and curl returns "Proxy connection failed" with nothing actionable in the log.

Affected call sites in `src/inference.cpp`:

  • `proxy_list_models()` → `proxy_request("/v1/models", ...)`
  • chat forwarding passes `/v1/chat/completions` through unmodified
  • streaming proxy same

Fix options

  1. Normalize on parse. In `config.cpp`, strip a trailing `/v1` (with or without slash) from `lm_proxy_url` before storing. Simple, invisible, matches user expectation.
  2. Normalize on use. In `forward_request`, if `base` ends in `/v1`, skip the `/v1` prefix in `path`. Slightly more magic, but handles CLI overrides too.
  3. Document and leave strict. Update `settings.ini` template + docs to be explicit that `lm_proxy_url` is origin-only, no `/v1`.

Preferred: (1) + better error messaging — strip the suffix during parse, and if `curl_easy_perform` fails, include the actual `curl_easy_strerror(res)` string in the error log rather than the generic "Proxy connection failed." Latter helps diagnose any remaining issue (DNS, TLS, refused) without a rebuild.

Acceptance

Activity

  1. diskerror commented on Jun 7, 2026

    @diskerror
    OwnerAuthor

    no longer applicable

  2. diskerror commented on Sep 5, 2026

    @diskerror
    OwnerAuthor

    Done — commit 20feb93 (Proxy: tolerate trailing /v1 in lm_proxy_url, issue #45), merged via fix/issue-45-trailing-v1 (17a12d3).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions