-
Notifications
You must be signed in to change notification settings - Fork 62
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
Proxy Support #43
Comments
Also the import { SocksProxyAgent } from 'socks-proxy-agent';
const agent = new SocksProxyAgent({/* credentials */});
const o = new Octokit({
request: { agent },
}); Octokit definitely works with proxies, see our test at https://github.com/octokit/core.js/blob/master/test/agent-proxy/agent-proxy-test.test.ts |
closing due to inactivity |
The same issue. Not working at all. But I found a solution, it seems working in nodejs environment import { SocksProxyAgent } from 'socks-proxy-agent';
import fetch from 'node-fetch'; // import node-fetch
const agent = new SocksProxyAgent({/* credentials */});
const o = new Octokit({
request: { agent, fetch },
}); |
@etnperlong Sorry to hear that you're having issues with proxies in Octokit! Have you tried this without customising |
@timrogers, we have been needing to use the workaround below to be able to use the proxy settings, but with the breaking changes in 8.0.0 this now fails as well, preventing an upgrade to 8.0.0. const { request } = require("@octokit/request");
const { Octokit } = require("@octokit/rest");
const { HttpsProxyAgent } = require('https-proxy-agent');
// configure the proxy if needed
if (process.env.HTTPS_PROXY) {
agent = new HttpsProxyAgent(process.env.HTTPS_PROXY);
} else if (process.env.https_proxy) {
agent = new HttpsProxyAgent(process.env.https_proxy);
}
// get a new client
const githubClient = new Octokit({
baseUrl: "https://api.github.com",
auth: process.env.GITHUB_TOKEN,
request: {
agent: agent,
timeout: 5000,
},
}); |
Yes, in v8 of Please see our test for how to implement proxy usage https://github.com/octokit/core.js/blob/73ce7fba8ec4184025c3359744935bed0b020bdf/test/agent-proxy/agent-proxy-test.test.ts#L18 You have to use the All usages of NodeJS based Proxies definitely do work with Octokit, it is a functionality that we account for in our tests |
Closing as this is not an issue. Proxies are supported, but due to the removal of |
For reference, here is how this is done with native fetch in NodeJS: import { ProxyAgent, fetch as undiciFetch } from "undici";
import { Octokit } from "@octokit/rest";
const myFetch = (url, opts) => {
return undiciFetch(url, {
...opts,
dispatcher: new ProxyAgent({
uri: process.env.HTTPS_PROXY,
keepAliveTimeout: 10,
keepAliveMaxTimeout: 10,
}),
});
};
const octokit = new Octokit({
baseUrl: serverUrl,
request: { fetch: myFetch },
}); |
What’s missing?
Proxy support. I googled "octokit proxy", and found 2-3 github issues describing adding proxy support to Octokit, but all of them led to 404 links (example 1 & 2).
Why?
In general, any HTTP client should support proxies.
Alternatives you tried
Here's what I tried with a Socks5 proxy:
But this doesn't work, the requests are still sent from my local machine's IP address.
The text was updated successfully, but these errors were encountered: