Skip to content

fix: route GHEC Copilot proxy to copilot-api subdomain#1331

Merged
lpcox merged 6 commits intomainfrom
copilot/fix-api-proxy-token-exchange
Mar 17, 2026
Merged

fix: route GHEC Copilot proxy to copilot-api subdomain#1331
lpcox merged 6 commits intomainfrom
copilot/fix-api-proxy-token-exchange

Conversation

Copy link
Contributor

Copilot AI commented Mar 17, 2026

On GHE Cloud data residency instances (*.ghe.com), the api-proxy was routing Copilot inference requests to api.<slug>.ghe.com, which returns 403/400 — the correct Copilot inference endpoint is copilot-api.<slug>.ghe.com (separate subdomain from the GitHub REST API).

Changes

  • containers/api-proxy/server.jsderiveCopilotApiTarget() now returns copilot-api.<slug>.ghe.com for all GHEC tenants instead of api.<slug>.ghe.com:

    GITHUB_SERVER_URL=https://acme.ghe.com
    Before: api.acme.ghe.com        ← GitHub REST API, returns 403 for Copilot
    After:  copilot-api.acme.ghe.com ← Copilot inference/models/MCP, works correctly
    
  • src/cli.tsextractGhecDomainsFromServerUrl() now auto-adds two additional domains to the firewall allowlist for GHEC instances:

    • copilot-api.<slug>.ghe.com — inference, models, MCP
    • copilot-telemetry-service.<slug>.ghe.com — telemetry

    Previously only <slug>.ghe.com and api.<slug>.ghe.com were auto-added; all four are now included.

  • docs/enterprise-configuration.md — updated GHEC examples and domain breakdowns to reflect all 4 auto-added domains and the corrected routing target.

  • Tests updated in server.test.js and src/cli.test.ts accordingly.


📍 Connect Copilot coding agent with Jira, Azure Boards or Linear to delegate work to Copilot in one click without leaving your project management tool.

Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix API proxy token exchange issue on GHE Cloud with data residency fix: route GHEC Copilot proxy to copilot-api subdomain Mar 17, 2026
Copilot AI requested a review from lpcox March 17, 2026 04:42
@lpcox lpcox marked this pull request as ready for review March 17, 2026 04:42
@lpcox lpcox requested a review from Mossaka as a code owner March 17, 2026 04:42
Copilot AI review requested due to automatic review settings March 17, 2026 04:42
@github-actions
Copy link
Contributor

github-actions bot commented Mar 17, 2026

Documentation Preview

Documentation build failed for this PR. View logs.

Built from commit 8e527e5

@github-actions
Copy link
Contributor

github-actions bot commented Mar 17, 2026

✅ Coverage Check Passed

Overall Coverage

Metric Base PR Delta
Lines 86.03% 86.16% 📈 +0.13%
Statements 85.96% 86.09% 📈 +0.13%
Functions 86.13% 86.13% ➡️ +0.00%
Branches 79.21% 79.28% 📈 +0.07%
📁 Per-file Coverage Changes (2 files)
File Lines (Before → After) Statements (Before → After)
src/cli.ts 61.1% → 61.2% (+0.13%) 61.5% → 61.6% (+0.13%)
src/docker-manager.ts 87.4% → 87.9% (+0.49%) 86.8% → 87.2% (+0.46%)

Coverage comparison generated by scripts/ci/compare-coverage.ts

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes AWF’s Copilot api-proxy routing for GitHub Enterprise Cloud data residency tenants (*.ghe.com) by targeting the correct Copilot inference subdomain and ensuring the firewall allowlist auto-includes the required GHEC Copilot domains.

Changes:

  • Update deriveCopilotApiTarget() to use copilot-api.<slug>.ghe.com for GHEC tenants.
  • Expand GHEC auto-allowlisting to include copilot-api.* and copilot-telemetry-service.* domains (in addition to tenant + api.*).
  • Refresh docs and tests to reflect the corrected routing/allowlisting behavior.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
containers/api-proxy/server.js Derives the correct GHEC Copilot upstream host (copilot-api.*) instead of the GitHub REST API host (api.*).
containers/api-proxy/server.test.js Updates expectations for GHEC target derivation behavior.
src/cli.ts Extends GHEC domain extraction so the firewall allowlist auto-includes Copilot inference + telemetry subdomains.
src/cli.test.ts Updates tests to assert the new extracted/auto-added GHEC domains.
docs/enterprise-configuration.md Updates examples and domain breakdowns for corrected GHEC routing and expanded auto-allowlisted domains.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

lpcox and others added 3 commits March 16, 2026 21:46
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@github-actions
Copy link
Contributor

🔥 Smoke Test Results

Test Result
GitHub MCP – last 2 merged PRs
Playwright – github.com title contains "GitHub"
File write /tmp/gh-aw/agent/smoke-test-copilot-23178913115.txt
Bash – file read back via cat

Last 2 merged PRs:

Assignees: @lpcox, @Copilot

Overall: PASS

📰 BREAKING: Report filed by Smoke Copilot for issue #1331

@github-actions

This comment has been minimized.

@github-actions
Copy link
Contributor

Smoke Test Results — Claude (claude-sonnet-4-6)

✅ GitHub MCP: #1316 fix: auto-inject GHEC tenant domains into firewall allowlist / #1321 chore: bump version to v0.24.2
✅ Playwright: github.com title contains "GitHub"
✅ File write: /tmp/gh-aw/agent/smoke-test-claude-23178913116.txt created
✅ Bash verify: file contents confirmed

Overall: PASS

💥 [THE END] — Illustrated by Smoke Claude for issue #1331

@github-actions
Copy link
Contributor

Chroot Version Comparison Results

Runtime Host Version Chroot Version Match?
Python Python 3.12.13 Python 3.12.3 ❌ NO
Node.js v24.14.0 v20.20.1 ❌ NO
Go go1.22.12 go1.22.12 ✅ YES

Result: ❌ Not all tests passed — Python and Node.js versions differ between host and chroot environments.

Tested by Smoke Chroot for issue #1331

@github-actions

This comment has been minimized.

)

* Initial plan

* fix: fix awf-runner timeout detection and no-docker test timeouts

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
@github-actions
Copy link
Contributor

🤖 Smoke test results for PR #1331 (@Copilot, assignees: @lpcox @Copilot)

✅ GitHub MCP — Last 2 merged PRs: #1332 "fix: fix awf-runner timeout detection and no-docker test timeouts", #1321 "chore: bump version to v0.24.2"
✅ Playwright — github.com title contains "GitHub"
✅ File write — /tmp/gh-aw/agent/smoke-test-copilot-23180056361.txt created
✅ Bash verify — file content confirmed

Overall: PASS

📰 BREAKING: Report filed by Smoke Copilot for issue #1331

@github-actions
Copy link
Contributor

Smoke Test (Codex Engine)
PR titles: #1332 fix: fix awf-runner timeout detection and no-docker test timeouts; #1316 fix: auto-inject GHEC tenant domains into firewall allowlist

  1. GitHub MCP review: ✅
  2. safeinputs-gh PR query: ❌ (tool unavailable in this runtime)
  3. Playwright github.com title check: ✅
  4. Tavily search: ❌ (tool unavailable in this runtime)
  5. File write test: ✅
  6. Bash cat readback: ✅
  7. Discussion query + mystical discussion comment: ❌ (required tools/endpoint unavailable)
  8. npm ci && npm run build: ✅
    Overall status: FAIL

🔮 The oracle has spoken through Smoke Codex

Warning

⚠️ Firewall blocked 2 domains

The following domains were blocked by the firewall during workflow execution:

  • ab.chatgpt.com
  • registry.npmjs.org

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "ab.chatgpt.com"
    - "registry.npmjs.org"

See Network Configuration for more information.

@github-actions
Copy link
Contributor

Chroot Version Comparison Results

Runtime Host Version Chroot Version Match?
Python Python 3.12.13 Python 3.12.3 ❌ NO
Node.js v24.14.0 v20.20.1 ❌ NO
Go go1.22.12 go1.22.12 ✅ YES

Overall result: ❌ FAILED — Python and Node.js versions differ between host and chroot environments.

Tested by Smoke Chroot for issue #1331

@github-actions
Copy link
Contributor

Smoke Test Results — Claude claude-sonnet-4-6

✅ GitHub MCP — last 2 merged PRs: "fix: fix awf-runner timeout detection and no-docker test timeouts" (#1332), "chore: bump version to v0.24.2" (#1321)
✅ Playwright — github.com title contains "GitHub"
✅ File write — /tmp/gh-aw/agent/smoke-test-claude-23180056355.txt created
✅ Bash verify — file content confirmed

Overall: PASS

💥 [THE END] — Illustrated by Smoke Claude for issue #1331

@github-actions
Copy link
Contributor

🏗️ Build Test Suite Results

Ecosystem Project Build/Install Tests Status
Bun elysia 1/1 passed ✅ PASS
Bun hono 1/1 passed ✅ PASS
C++ fmt N/A ✅ PASS
C++ json N/A ✅ PASS
Deno oak N/A 1/1 passed ✅ PASS
Deno std N/A 1/1 passed ✅ PASS
.NET hello-world N/A ✅ PASS
.NET json-parse N/A ✅ PASS
Go color 1/1 passed ✅ PASS
Go env 1/1 passed ✅ PASS
Go uuid 1/1 passed ✅ PASS
Java gson 1/1 passed ✅ PASS
Java caffeine 1/1 passed ✅ PASS
Node.js clsx All passed ✅ PASS
Node.js execa All passed ✅ PASS
Node.js p-limit All passed ✅ PASS
Rust fd 1/1 passed ✅ PASS
Rust zoxide 1/1 passed ✅ PASS

Overall: 8/8 ecosystems passed — ✅ PASS

Generated by Build Test Suite for issue #1331 ·

@lpcox lpcox merged commit 2e7e15a into main Mar 17, 2026
62 checks passed
@lpcox lpcox deleted the copilot/fix-api-proxy-token-exchange branch March 17, 2026 06:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

API proxy token exchange fails on GHE Cloud with data residency (400/403)

3 participants