New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Respect https_proxy environment variables by default. #2098
Comments
A But you can quite easily create your own Octokit constructor which respects the environment variable. Try this // octokit plugin
function autoProxyAgent(octokit, options) {
const proxy = process.env.https_proxy || process.env.HTTPS_PROXY;
if (!proxy) return
const agent = new HttpsProxyAgent(proxy)
octokit.hook.before("request", (options) => {
options.request.agent = agent
});
}
const MyOctokit = Octokit.plugin(autoProxyAgent);
const octokit = new MyOctokit(); You could publish the |
Unfortunately those fixes aren't going to work for my use cases. The issue is not with my code, rather with tools already written by third parties. Your suggested fix is essentially what I have been doing, fork the third party code and modify to respect proxy, I was just hoping for a better solution. Thanks for the explanation as to why this wouldn't be added though. I suppose in this case the responsibility is upon authors to make sure their tools are widely useable for their intended purpose. |
@gr2m Thank you for the snippet to support At the moment, most GitHub actions are broken for those that run self-hosted runners behind a corporate proxy. It might be worth having an official Octokit plugin for "autoProxyAgent" because I think ideally it should be included in the Actions Tookit Could be included here: |
Good point! I’ll incorporate it into @octokit/action, I want to rework this one anyway |
you can follow octokit/action.js#300 for updates |
@gr2m Just to clarify, can we expect a standalone |
Not sure yet. But you can use the above code as plug-in already |
Yep, that's what I'm intending to do here. I just thought it would be easier to support this feature in the wider community if it was standalone. |
What’s missing?
Currently, octokit requires code in order to respect https_proxy environment variables, which looks something like this.
It would be nice if octokit can automatically read
https_proxy
(and the others) and respect those environment variables.Why?
Not having this feature creates a problem with the proliferation of third party tools that don't specifically add something like the above code to enable running behind a proxy.
My specific use case involves github actions. We have requirements to run actions on self-hosted runners that sit behind a proxy. We are able to make requests from our runners to the github API through the proxy, but any action that uses octokit and does NOT include the code above fails.
Alternatives you tried
We are currently forced to fork and modify every javascript action that uses octokit just to get the action to work on our self-hosted runners that sit behind a proxy. This process is somewhat time-consuming to do, and VERY time consuming keep forks up to date with the base repo. There are instances of other, non-github action tools where we have had to do the same as well.
The text was updated successfully, but these errors were encountered: