Skip to content

Support non-Individual Copilot API hosts (GHE / Business / Enterprise) for github-copilot-enhanced #5

Description

@ksulli

The github-copilot-enhanced script hardcodes https://api.individual.githubcopilot.com, so background sync (Ne/Pe) fails on GitHub Enterprise, where the host differs (e.g. copilot-api..ghe.com). The fetch-interception hooks already work since they match on path, but the script's own API calls don't.

Could the API origin be auto-detected (e.g. captured from intercepted /github/chat/threads requests) with an optional override? I'm happy to contribute — is the source available somewhere to PR against? The repo appears to contain only the built .user.js.

Copilot suggests something like this:

// Replace the constant with a mutable value + a captured origin.
let copilotApiOrigin = `https://api.individual.githubcopilot.com`; // sensible default

// In the fetch interceptor, learn the real origin from actual Copilot traffic:
function maybeCaptureApiOrigin(url) {
  try {
    const u = new URL(url);
    if (/\/github\/chat\/threads/.test(u.pathname)) {
      copilotApiOrigin = u.origin; // e.g. https://copilot-api.<company>.ghe.com
    }
  } catch { /* ignore */ }
}

// Then Ne()/Pe() build URLs from copilotApiOrigin instead of the constant Me.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions