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

How can I use a proxy like in axios? #526

Closed
MiniSuperDev opened this issue Sep 14, 2023 · 2 comments
Closed

How can I use a proxy like in axios? #526

MiniSuperDev opened this issue Sep 14, 2023 · 2 comments

Comments

@MiniSuperDev
Copy link

axios({
  proxy: {
    protocol: 'https',
    host: '127.0.0.1',
    port: 9000,
    auth: {
      username: 'mikeymike',
      password: 'rapunz3l'
    }
})

Thanks

@sindresorhus
Copy link
Owner

If this is about Node.js, https://github.com/gajus/global-agent is usually the go to tool for this, unfortunately, it doesn't yet support: gajus/global-agent#52

Proxy support is not something we plan to or can support built-in here.

@sindresorhus sindresorhus closed this as not planned Won't fix, can't repro, duplicate, stale Sep 28, 2023
@transitive-bullshit
Copy link

From what I've found, the easiest way to use a proxy with Node.js fetch (and hence ky) is via undici's experimental EnvHttpProxyAgent, which will respect the HTTP_PROXY, HTTPS_PROXY, and NO_PROXY environment variables.

npm install undici
import { EnvHttpProxyAgent } from 'undici'
import ky from 'ky'

const kyWithProxy = ky.extend({ dispatcher: new EnvHttpProxyAgent() })

This obviously won't work outside of Node.js, but it's still useful to know about.

JonasSchubert added a commit to JonasSchubert/semantic-release-presets that referenced this issue Dec 10, 2024
github-actions bot pushed a commit to JonasSchubert/semantic-release-presets that referenced this issue Dec 10, 2024
## [5.0.1](v5.0.0...v5.0.1) (2024-12-10)

### Bug Fixes

* **ms-teams:** use undici experimental EnvHttpProxyAgent for proxies ([44e2811](44e2811)), closes [/github.com/sindresorhus/ky/issues/526#issuecomment-2390430300](https://github.com//github.com/sindresorhus/ky/issues/526/issues/issuecomment-2390430300)
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

No branches or pull requests

3 participants