• keh4l's avatar
    fix(gateway): skip client header passthrough on OAuth mimicry path · bdbd2916
    keh4l authored
    Root cause of persistent third-party detection: sub2api's
    buildUpstreamRequest transparently forwards client headers via
    allowedHeaders whitelist (addHeaderRaw) before applying mimicry
    overrides. When third-party clients (opencode, etc.) send their own
    anthropic-beta / user-agent / x-stainless-* / x-claude-code-session-id
    values, these get appended to the request alongside our injected
    headers, creating an inconsistent header set that Anthropic detects.
    
    Parrot's build_upstream_headers constructs exactly 9 headers from
    scratch and never forwards anything from the client. This is why
    'same opencode version, some users work some don't' — different
    opencode configs/versions send different header combinations.
    
    Fix: when tokenType=oauth and mimicClaudeCode=true, skip the
    client header passthrough loop entirely. The subsequent
    applyClaudeCodeMimicHeaders + ApplyFingerprint + beta merge
    pipeline constructs all necessary headers from our controlled values.
    
    Also: remove systemIncludesClaudeCodePrompt gate — OAuth accounts
    now unconditionally rewrite system (even if client already sent a
    Claude Code-style prompt), ensuring billing attribution block is
    always present.
    bdbd2916
gateway_service.go 314 KB