Skip to content

feat(proxy): make Copilot API target configurable for enterprise environments#1064

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/sub-pr-1063
Draft

feat(proxy): make Copilot API target configurable for enterprise environments#1064
Copilot wants to merge 2 commits intomainfrom
copilot/sub-pr-1063

Conversation

Copy link
Contributor

Copilot AI commented Feb 26, 2026

When running in GHEC/GHES environments, the api-proxy sidecar was hardcoded to route Copilot traffic to api.githubcopilot.com, breaking enterprise deployments that require api.enterprise.githubcopilot.com.

Changes

  • Auto-derivation: api-proxy now detects non-github.com GITHUB_SERVER_URL and automatically routes to api.enterprise.githubcopilot.com
  • Explicit override: COPILOT_API_TARGET env var and --copilot-api-target CLI flag allow overriding the target hostname
  • Input validation: COPILOT_API_TARGET is normalized — full URLs are parsed to extract hostname, bare hostnames are validated to reject paths/whitespace
  • Env forwarding: GITHUB_SERVER_URL and GITHUB_API_URL are forwarded from the host into both the agent and api-proxy containers
  • Precedence: COPILOT_API_TARGET > derived from GITHUB_SERVER_URL > api.githubcopilot.com

Target derivation logic (api-proxy)

// COPILOT_API_TARGET wins if set
// Otherwise, non-github.com GITHUB_SERVER_URL → enterprise endpoint
// Otherwise, public default
function deriveCopilotApiTarget() {
  const envTarget = process.env.COPILOT_API_TARGET;
  if (envTarget) return normalizeHostname(envTarget);

  const serverUrl = process.env.GITHUB_SERVER_URL;
  if (serverUrl) {
    const hostname = new URL(serverUrl).hostname;
    if (hostname !== 'github.com') return 'api.enterprise.githubcopilot.com';
  }

  return 'api.githubcopilot.com';
}

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

lpcox and others added 2 commits February 26, 2026 09:05
…ronments

Auto-derive api.enterprise.githubcopilot.com from GITHUB_SERVER_URL when
the server is not github.com (GHEC/GHES). Allow explicit override via
COPILOT_API_TARGET env var or --copilot-api-target CLI flag. Forward
GITHUB_SERVER_URL and GITHUB_API_URL to both agent and api-proxy containers
by default.
Copilot AI changed the title [WIP] Add enterprise API target configuration for Copilot feat(proxy): make Copilot API target configurable for enterprise environments Feb 26, 2026
Base automatically changed from lpcox/configure-api-proxy-target to main February 26, 2026 17:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants