Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Best Practise Proxy Support πŸ˜€πŸ‘πŸΌΒ #54

@NickLiffen

Description

@NickLiffen

Hey πŸ‘‹πŸ»,

I have a question, we are looking to use this module alongside the @octokit/graphql.js.

We work behind a corporate proxy, so we need to be able to pass a proxy to any egress request from within our network.

I see that both this and the @octokit/graphql.js modules use the @octokit/request.js) module to make its requests to the GitHub API.

By taking a look at your code, you seem to be using node-fetch for actually making the HTTP Requests behind the scenes.

Taking a look at node-fetch it does support passing in an agent. When taking a look at your request library, there doesn't seem to be any options, which I would have expected to see here? (maybe?)

We would love to be able to pass in a httpsAgent somewhere?

const { createAppAuth } = require("@octokit/auth-app");
const httpAgent = new http.Agent({ keepAlive: true });
const httpsAgent = new https.Agent({ keepAlive: true });

const auth = createAppAuth({
  id: 1,
  privateKey: "-----BEGIN PRIVATE KEY-----\n...",
  installationId: 123,
  clientId: "1234567890abcdef1234",
  clientSecret: "1234567890abcdef12341234567890abcdef1234"
});

const installationAuthentication = await auth({ 
  type: "installation" ,
  agent: url => url.protocol === 'https:' ? httpsAgent : httpAgent
});

const graphqlWithAuth = graphql.defaults({
  request: {
    hook: auth.hook
    agent: url => url.protocol === 'https:' ? httpsAgent : httpAgent
  }
});

Something like that? It would be great if we could do this in a single place when looking through the octokit modules, it would be great to have a single experience across the @octokit ecosystem πŸ€”?

Just wanted to put it here and get some of your thoughts on best practice πŸ‘

Thanks for all your help.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions