Describe the bug
When using @github/copilot-sdk v0.3.0 (CLI v1.0.36) in headless mode behind a corporate HTTP proxy, session.create fails with "fetch failed". The CLI subprocess receives all proxy env vars correctly, and standalone undici 7.22 can reach api.github.com through the same proxy from the same container — but the CLI's internal fetch ignores the proxy.
This is a regression from CLI v0.0.394 where the same setup worked.
Key evidence
-
Standalone undici works — from inside the Docker container:
undici version: 7.22.0
Status: 200
Body: {"login":"...", "copilot_plan":"copilot_for_business"...}
-
curl works — through the same proxy:
curl -x http://proxy:443 https://api.github.com/copilot_internal/user → 200
-
CLI subprocess gets proxy env — confirmed by intercepting child_process.spawn:
SPAWN command: node /app/node_modules/@github/copilot/index.js --headless --no-auto-update
SPAWN HTTPS_PROXY: http://proxy:443
SPAWN HTTP_PROXY: http://proxy:443
SPAWN NODE_TLS_REJECT_UNAUTHORIZED: 0
SPAWN env: COPILOT_SDK_AUTH_TOKEN = gho_xxx...
-
CLI fails anyway:
FAILED: Request session.create failed with message: fetch failed
-
No TLS MITM — the proxy does transparent CONNECT (real *.github.com cert from Sectigo, not a proxy-injected cert):
subject=CN = *.github.com
issuer=C = GB, O = Sectigo Limited, CN = Sectigo Public Server Authentication CA DV E36
-
NODE_EXTRA_CA_CERTS doesn't help — tested with the full cert chain, same result
Version comparison
| Component |
Working |
Broken |
@github/copilot-sdk |
0.1.19 |
0.3.0 |
@github/copilot CLI |
0.0.394 |
1.0.36 |
| Node.js |
v22.22.0 |
v22.22.0 |
| Result |
Sessions work |
"fetch failed" |
Affected version
GitHub Copilot CLI 1.0.36
Steps to reproduce the behavior
- Run in a Docker container with
HTTPS_PROXY set to a corporate HTTP CONNECT proxy
- Install
@github/copilot-sdk@0.3.0 + @github/copilot@1.0.36
- Create a CopilotClient with
gitHubToken and start it:
const { CopilotClient } = require("@github/copilot-sdk");
const client = new CopilotClient({ gitHubToken: token, useLoggedInUser: false });
await client.start();
- Call
createSession with gitHubToken:
const session = await client.createSession({
model: "gpt-4o",
gitHubToken: token,
streaming: false,
systemMessage: { content: "Be brief." },
onPermissionRequest: () => ({ result: "allow" }),
});
- Observe:
Request session.create failed with message: fetch failed
Expected behavior
session.create should respect HTTPS_PROXY / HTTP_PROXY environment variables for its internal auth fetch to api.github.com, the same way standalone undici 7.22 does from the same container.
Additional context
Describe the bug
When using
@github/copilot-sdkv0.3.0 (CLI v1.0.36) in headless mode behind a corporate HTTP proxy,session.createfails with "fetch failed". The CLI subprocess receives all proxy env vars correctly, and standaloneundici7.22 can reachapi.github.comthrough the same proxy from the same container — but the CLI's internal fetch ignores the proxy.This is a regression from CLI v0.0.394 where the same setup worked.
Key evidence
Standalone undici works — from inside the Docker container:
curl works — through the same proxy:
CLI subprocess gets proxy env — confirmed by intercepting
child_process.spawn:CLI fails anyway:
No TLS MITM — the proxy does transparent CONNECT (real
*.github.comcert from Sectigo, not a proxy-injected cert):NODE_EXTRA_CA_CERTS doesn't help — tested with the full cert chain, same result
Version comparison
@github/copilot-sdk@github/copilotCLIAffected version
GitHub Copilot CLI 1.0.36
Steps to reproduce the behavior
HTTPS_PROXYset to a corporate HTTP CONNECT proxy@github/copilot-sdk@0.3.0+@github/copilot@1.0.36gitHubTokenand start it:createSessionwithgitHubToken:Request session.create failed with message: fetch failedExpected behavior
session.createshould respectHTTPS_PROXY/HTTP_PROXYenvironment variables for its internal auth fetch toapi.github.com, the same way standalone undici 7.22 does from the same container.Additional context
node:22-alpine), Linux x86_64resolveSessionAuth()→ internal token validation fetch toapi.github.com/copilot_internal/user— this fetch does not go through the proxyclient.start()→trySdkTokenLogin()→ same fetch failure, but caught silently. CLI boots with no auth. The session-level auth then fails loudly.provider: { type: "openai", baseUrl: "https://api.business.githubcopilot.com", bearerToken: token }increateSessionbypasses the failing fetch and works — but only for GPT models (Claude/Gemini not available via this endpoint)web_fetchand auto-update fail withTypeError: fetch failedbehind corporate proxy #2395, Failed to list available models due to duplicate CA certificates from combined system and bundled certs #869@github/copilot-sdk@0.1.19/@github/copilot@0.0.394