Open xiangxn opened 9 months ago
This is great! This fix makes near-cli usable for developers who need http(s) proxies to visit NEAR RPC and helper services.
Can you make some enhancements to support HTTP_PROXY
, HTTPS_PROXY
and NO_PROXY
environment variables?
These are all supported, please check for details: https://github.com/gajus/global-agent
I mean after import global agent, you can configure the global agent environment variables, so near-cli acts more like a normal process that respects the environment variables HTTP_PROXY
, HTTPS_PROXY
and NO_PROXY
.
function setProxies() {
const http_proxy = process.env.http_proxy || process.env.HTTP_PROXY;
if (http_proxy) {
global.GLOBAL_AGENT.HTTP_PROXY = http_proxy;
}
const https_proxy = process.env.https_proxy || process.env.HTTPS_PROXY;
if (https_proxy) {
global.GLOBAL_AGENT.HTTPS_PROXY = https_proxy;
}
const no_proxy = process.env.no_proxy || process.env.NO_PROXY;
if (no_proxy) {
global.GLOBAL_AGENT.NO_PROXY = no_proxy;
}
}
I mean after import global agent, you can configure the global agent environment variables, so near-cli acts more like a normal process that respects the environment variables
HTTP_PROXY
,HTTPS_PROXY
andNO_PROXY
.function setProxies() { const http_proxy = process.env.http_proxy || process.env.HTTP_PROXY; if (http_proxy) { global.GLOBAL_AGENT.HTTP_PROXY = http_proxy; } const https_proxy = process.env.https_proxy || process.env.HTTPS_PROXY; if (https_proxy) { global.GLOBAL_AGENT.HTTPS_PROXY = https_proxy; } const no_proxy = process.env.no_proxy || process.env.NO_PROXY; if (no_proxy) { global.GLOBAL_AGENT.NO_PROXY = no_proxy; } }
Updated to support these environment variables by default.
you only need to set the environment variable:
export GLOBAL_AGENT_HTTP_PROXY="http://127.0.0.1:8001"
View in detail: https://github.com/gajus/global-agent