Closed Genteure closed 8 months ago
node 20.6.1 giget 1.1.3
Start any proxy server with logging:
// https://github.com/berstend/straightforward $ npx straightforward straightforward forward-proxy running on localhost:9191
Set environment variable
$env:HTTPS_PROXY="http://127.0.0.1:9191"
export HTTPS_PROXY="http://127.0.0.1:9191"
Run curl -x http://127.0.0.1:9191 https://example.com to confirm the proxy is working and is printing proxy connections:
curl -x http://127.0.0.1:9191 https://example.com
CONNECT example.com:443
Run npx giget github:withastro/astro/examples/basics#latest ./output --force-clean --verbose.
npx giget github:withastro/astro/examples/basics#latest ./output --force-clean --verbose
No connection is made through the proxy.
giget should use the proxy set in environment variable.
https://github.com/unjs/node-fetch-native/blob/47e92fdae1356d3970e40dfafa5614d2c0f68a87/src/index.ts#L22-L29 giget by default is using node's built in fetch in node 20.
fetch
The built-in fetch is the same as undici.fetch. https://github.com/nodejs/node/blob/3e14cfbbcfcedbb18235ffd5cc28983ac5d5ca52/lib/internal/process/pre_execution.js#L314-L316
undici.fetch
undici does not support http.Agent but uses a different API: https://undici.nodejs.org/#/docs/api/ProxyAgent
http.Agent
Workaround: set the environment variable FORCE_NODE_FETCH.
FORCE_NODE_FETCH
No response
Same here. I can't download template in create-astro
create-astro
The solution provided is useful, set FORCE_NODE_FETCH=1
for powershell, as follows: $ENV:FORCE_NODE_FETCH=1
$ENV:FORCE_NODE_FETCH=1
Proxy support is added in the latest version of giget for Node.js versions with native fetch (undici) (read more)
You can get the feature by upgrading your lockfile.
Environment
node 20.6.1 giget 1.1.3
Reproduction
Start any proxy server with logging:
Set environment variable
Run
curl -x http://127.0.0.1:9191 https://example.com
to confirm the proxy is working and is printing proxy connections:Run
npx giget github:withastro/astro/examples/basics#latest ./output --force-clean --verbose
.No connection is made through the proxy.
Describe the bug
giget should use the proxy set in environment variable.
https://github.com/unjs/node-fetch-native/blob/47e92fdae1356d3970e40dfafa5614d2c0f68a87/src/index.ts#L22-L29 giget by default is using node's built in
fetch
in node 20.The built-in
fetch
is the same asundici.fetch
. https://github.com/nodejs/node/blob/3e14cfbbcfcedbb18235ffd5cc28983ac5d5ca52/lib/internal/process/pre_execution.js#L314-L316undici does not support
http.Agent
but uses a different API: https://undici.nodejs.org/#/docs/api/ProxyAgentAdditional context
Workaround: set the environment variable
FORCE_NODE_FETCH
.Logs
No response