musistudio/claude-code-router · error · Error

New API provider base URL is missing.

Error message

New API provider base URL is missing.

What it means

The connector computes the provider root URL from options.baseUrl or the provider record's base URL; if neither yields a usable root via newApiRootBaseUrl, it throws. This is a connector configuration problem, not a network error.

Source

Thrown at packages/electron/bundled-plugins/new-api-account/index.cjs:30

      providerAccountConnectors: [
        {
          id: CONNECTOR_ID,
          resolve: resolveSubscriptionSelf
        }
      ]
    };
  }
};

async function resolveSubscriptionSelf(request) {
  if (typeof request.fetchProviderAccountJson !== "function") {
    throw new Error("New API account connector requires CCR Desktop browser account fetch support.");
  }

  const options = isRecord(request.connector?.options) ? request.connector.options : {};
  const root = newApiRootBaseUrl(readString(options.baseUrl) || providerBaseUrl(request.provider));
  if (!root) {
    throw new Error("New API provider base URL is missing.");
  }

  const timeoutMs = normalizeTimeoutMs(options.timeoutMs);
  const requestOrigin = readString(options.requestOrigin) || root;
  const refreshPayload = await request.fetchProviderAccountJson({
    body: options.refreshBody ?? {},
    credentials: "include",
    endpoint: rootUrl(root, readString(options.refreshPath) || DEFAULT_REFRESH_PATH),
    headers: readStringRecord(options.refreshHeaders),
    method: "POST",
    requestOrigin,
    timeoutMs
  });
  assertSuccessfulPayload(refreshPayload, "New API refresh");

  const token = refreshTokenFromPayload(refreshPayload);
  if (!token) {
    throw new Error("New API refresh response did not include an access token.");

View on GitHub (pinned to 99f24806c6)

Solutions

  1. Set connector.options.baseUrl to a valid absolute URL, e.g. https://api.example.com
  2. Verify the provider record passed in request.provider actually contains its base URL
  3. Trim/validate baseUrl at connector-save time and reject empty values early
  4. Check newApiRootBaseUrl's accepted formats if using an unusual URL shape

Example fix

// before
const options = {}; // no baseUrl, provider.baseUrl undefined -> throws

// after
const options = { baseUrl: 'https://api.example.com' };
Defensive patterns

Strategy: validation

Validate before calling

const root = newApiRootBaseUrl(readString(options.baseUrl) || providerBaseUrl(provider));
if (!root) throw new ConfigError('Set connector options.baseUrl to e.g. https://api.example.com');

Type guard

function isValidBaseUrl(v: unknown): v is string {
  try { const u = new URL(String(v)); return u.protocol === 'https:' || u.protocol === 'http:'; } catch { return false; }
}

Try / catch

null

Prevention

When it happens

Trigger: options.baseUrl absent/empty/whitespace AND provider.baseUrl missing or unparseable; baseUrl with only a scheme like 'https://' or a path that normalizes away.

Common situations: Connector created without setting baseUrl, provider record malformed after import/migration, typo like 'htp://api.example.com', or trailing-slash/query-only URLs rejected by normalization.

Understand the failure class

Background: "environment variable is not set" and "Missing keys in environment" errors: what missing required env var messages mean and how to fix them — this error's family across 28 libraries.

Related errors


AI-assisted analysis of musistudio/claude-code-router@99f24806c6 (2026-08-27). Data as JSON: /api/errors/d5999bae7cd5ac08. Report an issue: GitHub.