Skip to content
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

Does not use http proxy on node 20 #120

Closed
Genteure opened this issue Nov 10, 2023 · 3 comments · Fixed by #133
Closed

Does not use http proxy on node 20 #120

Genteure opened this issue Nov 10, 2023 · 3 comments · Fixed by #133

Comments

@Genteure
Copy link

Environment

node 20.6.1
giget 1.1.3

Reproduction

  1. Start any proxy server with logging:

    // https://github.com/berstend/straightforward
    $ npx straightforward
    
          straightforward forward-proxy running on localhost:9191
  2. Set environment variable

    $env:HTTPS_PROXY="http://127.0.0.1:9191"
    export HTTPS_PROXY="http://127.0.0.1:9191"
  3. Run curl -x http://127.0.0.1:9191 https://example.com to confirm the proxy is working and is printing proxy connections:

             CONNECT         example.com:443
    
  4. 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 as undici.fetch.
https://github.com/nodejs/node/blob/3e14cfbbcfcedbb18235ffd5cc28983ac5d5ca52/lib/internal/process/pre_execution.js#L314-L316

undici does not support http.Agent but uses a different API: https://undici.nodejs.org/#/docs/api/ProxyAgent

Additional context

Workaround: set the environment variable FORCE_NODE_FETCH.

Logs

No response

@MarvinXu
Copy link

Same here. I can't download template in create-astro

@YadongChen
Copy link

The solution provided is useful, set FORCE_NODE_FETCH=1

for powershell, as follows: $ENV:FORCE_NODE_FETCH=1

@pi0
Copy link
Member

pi0 commented Dec 24, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants