mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-07-24 21:30:17 +08:00
feat(proxy): honor custom User-Agent across stream check and model fetch
Extract a shared `parse_custom_user_agent` helper in provider.rs returning `Result<Option<HeaderValue>>`, and reuse it in the forwarder, stream check, and model fetch paths so detection, forwarding, and model listing all apply the same provider-level User-Agent. Previously only the forwarder honored it, so stream check could fail (or model listing 403) on UA-gated upstreams that the proxy itself handled fine. - stream_check injects the provider's custom UA on the claude/codex paths and still skips the GitHub Copilot fingerprint UA. - model_fetch service + command and the model-fetch.ts wrapper thread an optional UA through to GET /v1/models. - runtime callers silently ignore invalid values via `.ok().flatten()` (no save-time block, so deeplink imports stay lenient).
This commit is contained in:
@@ -18,12 +18,14 @@ export async function fetchModelsForConfig(
|
||||
apiKey: string,
|
||||
isFullUrl?: boolean,
|
||||
modelsUrl?: string,
|
||||
customUserAgent?: string,
|
||||
): Promise<FetchedModel[]> {
|
||||
return invoke("fetch_models_for_config", {
|
||||
baseUrl,
|
||||
apiKey,
|
||||
isFullUrl,
|
||||
modelsUrl,
|
||||
customUserAgent,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user