A small, reversible fix for CodeBuddy Code CLI login failures on Windows:
Login failed: TypeError: Cannot read properties of undefined (reading 'protocol')
Failed to login. Press esc to return to login
This issue can appear after selecting Chinese Site, especially on Windows 11 machines using Clash, Mihomo, Clash Party, or another system proxy.
Open PowerShell and run:
git clone https://github.com/diyqiao/codebuddy-login-fix-windows.git
cd codebuddy-login-fix-windows
powershell -ExecutionPolicy Bypass -File .\fix-codebuddy-login.ps1Then close every CodeBuddy process and terminal window. Open a new PowerShell window:
codebuddySelect Chinese Site and press Enter.
The script adds these CodeBuddy endpoints to the user-level NO_PROXY and no_proxy variables:
copilot.tencent.com
staging-copilot.tencent.com
galileotelemetry.tencent.com
It preserves existing entries, creates a backup, and checks the China authentication endpoint. It does not collect credentials, modify CodeBuddy tokens, disable Clash, or change the Windows system proxy.
Backup location:
%LOCALAPPDATA%\CodeBuddyLoginFix\env-backup.json
To restore the previous values:
powershell -ExecutionPolicy Bypass -File .\restore-codebuddy-login-env.ps1In the reproduced environment, CodeBuddy Code CLI v2.129.0 failed before sending the authentication request when its Windows proxy path was used. The same China authentication endpoint returned HTTP 200 when accessed directly. Bypassing the proxy only for CodeBuddy authentication endpoints avoided the failing proxy parsing path while leaving the system proxy enabled.
This repository documents an observed workaround, not an official Tencent patch. A later CodeBuddy release may fix the underlying proxy handling.
If you do not want to run the script:
$current = [Environment]::GetEnvironmentVariable('NO_PROXY', 'User')
$value = "$current,copilot.tencent.com,staging-copilot.tencent.com,galileotelemetry.tencent.com"
[Environment]::SetEnvironmentVariable('NO_PROXY', $value.Trim(','), 'User')
[Environment]::SetEnvironmentVariable('no_proxy', $value.Trim(','), 'User')Restart all terminals afterward.
codebuddy --version
node --version
[Environment]::GetEnvironmentVariable('NO_PROXY', 'User')
Test-NetConnection copilot.tencent.com -Port 443CodeBuddy logs are normally stored under:
%USERPROFILE%\.codebuddy\logs
Before opening an issue, remove tokens, usernames, local paths, trace IDs, and other private data from logs.
CodeBuddy cannot login, CodeBuddy login failed, CodeBuddy Chinese Site login, CodeBuddy China login, CodeBuddy protocol undefined, Cannot read properties of undefined reading protocol, Tencent CodeBuddy CLI, Windows 11, PowerShell, Clash, Clash Party, Mihomo, proxy, OAuth.