Skip to content

Commit dce0ab0

Browse files
committed
fix: remove custom proxy handling (#143)
Undici has added native support for proxy handling, so it is no longer necessary for us to have our own custom proxy handling. Reverts #102 and resolves #134. (cherry picked from commit cda91bf)
1 parent 2e564a0 commit dce0ab0

File tree

3 files changed

+5
-35
lines changed

3 files changed

+5
-35
lines changed

lib/request.js

Lines changed: 3 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,11 @@
11
import * as core from "@actions/core";
22
import { request } from "@octokit/request";
3-
import { ProxyAgent, fetch as undiciFetch } from "undici";
43

4+
// Get the GitHub API URL from the action input and remove any trailing slash
55
const baseUrl = core.getInput("github-api-url").replace(/\/$/, "");
66

7-
// https://docs.github.com/actions/hosting-your-own-runners/managing-self-hosted-runners/using-a-proxy-server-with-self-hosted-runners
8-
const proxyUrl =
9-
process.env.https_proxy ||
10-
process.env.HTTPS_PROXY ||
11-
process.env.http_proxy ||
12-
process.env.HTTP_PROXY;
13-
14-
/* c8 ignore start */
15-
// Native support for proxies in Undici is under consideration: https://github.com/nodejs/undici/issues/1650
16-
// Until then, we need to use a custom fetch function to add proxy support.
17-
const proxyFetch = (url, options) => {
18-
const urlHost = new URL(url).hostname;
19-
const noProxy = (process.env.no_proxy || process.env.NO_PROXY || "").split(
20-
",",
21-
);
22-
23-
if (!noProxy.includes(urlHost)) {
24-
options = {
25-
...options,
26-
dispatcher: new ProxyAgent(String(proxyUrl)),
27-
};
28-
}
29-
30-
return undiciFetch(url, options);
31-
};
32-
/* c8 ignore stop */
33-
7+
// Configure the default settings for GitHub API requests
348
export default request.defaults({
35-
headers: {
36-
"user-agent": "actions/create-github-app-token",
37-
},
9+
headers: { "user-agent": "actions/create-github-app-token" },
3810
baseUrl,
39-
/* c8 ignore next */
40-
request: proxyUrl ? { fetch: proxyFetch } : {},
4111
});

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@
1919
"@actions/core": "^3.0.0",
2020
"@octokit/auth-app": "^8.2.0",
2121
"@octokit/request": "^10.0.8",
22-
"p-retry": "^7.1.1",
23-
"undici": "^7.24.1"
22+
"p-retry": "^7.1.1"
2423
},
2524
"devDependencies": {
2625
"@octokit/openapi": "^21.0.0",
@@ -31,6 +30,7 @@
3130
"esbuild": "^0.27.3",
3231
"execa": "^9.6.1",
3332
"open-cli": "^8.0.0",
33+
"undici": "^7.24.1",
3434
"yaml": "^2.8.2"
3535
},
3636
"release": {

tests/snapshots/index.js.snap

4 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)