fix: require NODE_USE_ENV_PROXY for proxy support (#342)
This PR switches proxy support to Node's native env-proxy handling and makes the required configuration explicit. ## What changed - fail fast in both `main` and `post` when proxy configuration is present without `NODE_USE_ENV_PROXY=1` - document the supported proxy configuration in `README.md` - add regression tests for the proxy guard in both entrypoints - keep the existing successful end-to-end coverage and add a smaller proxy-specific workflow check that enables native proxy support, points `https_proxy` at an unreachable proxy, and asserts the action fails - update the test workflow so the same checks also run on pushes to `beta` ## Proxy configuration When using `HTTP_PROXY` or `HTTPS_PROXY`, set `NODE_USE_ENV_PROXY=1` on the action step. If you need bypass rules, set `NO_PROXY` alongside them. --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
Vendored
+25
-1
@@ -20485,13 +20485,37 @@ var request = withDefaults2(endpoint, defaults_default);
|
||||
|
||||
// lib/request.js
|
||||
var baseUrl = import_core.default.getInput("github-api-url").replace(/\/$/, "");
|
||||
var proxyEnvironmentKeys = [
|
||||
"https_proxy",
|
||||
"HTTPS_PROXY",
|
||||
"http_proxy",
|
||||
"HTTP_PROXY"
|
||||
];
|
||||
function proxyEnvironmentConfigured() {
|
||||
return proxyEnvironmentKeys.some((key) => process.env[key]);
|
||||
}
|
||||
function nativeProxySupportEnabled() {
|
||||
return process.env.NODE_USE_ENV_PROXY === "1";
|
||||
}
|
||||
function ensureNativeProxySupport() {
|
||||
if (!proxyEnvironmentConfigured() || nativeProxySupportEnabled()) {
|
||||
return;
|
||||
}
|
||||
throw new Error(
|
||||
"A proxy environment variable is set, but Node.js native proxy support is not enabled. Set NODE_USE_ENV_PROXY=1 for this action step."
|
||||
);
|
||||
}
|
||||
var request_default = request.defaults({
|
||||
headers: { "user-agent": "actions/create-github-app-token" },
|
||||
baseUrl
|
||||
});
|
||||
|
||||
// post.js
|
||||
post(import_core2.default, request_default).catch((error) => {
|
||||
async function run() {
|
||||
ensureNativeProxySupport();
|
||||
return post(import_core2.default, request_default);
|
||||
}
|
||||
run().catch((error) => {
|
||||
console.error(error);
|
||||
import_core2.default.setFailed(error.message);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user