undici-noproxy
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

undici-noproxy

no_proxy ProxyAgent for undici

An undici ProxyAgent which considers http(s)_proxy and no_proxy env-vars or settings.

usage

npm i undici-noproxy

proxy settings in code

import { request } from 'undici'
import { NoProxyAgent } from 'undici-noproxy'

const proxyAgent = new NoProxyAgent({
  uri: 'http://my-http.proxy',
  protocol: 'http',
  noProxy: 'localhost,.my.domain'
})

const res = await request('https://httpbin.org/anything', { dispatcher: proxyAgent })
const json = await res.body.json()
proxyAgent.close()

proxy settings via env vars

http_proxy=http://my-http.proxy
no_proxy=localhost,.my.domain

NoProxyAgent considers the settings from the given env-vars...

import { request } from 'undici'
import { NoProxyAgent } from 'undici-noproxy'

const proxyAgent = new NoProxyAgent()

const res = await request('https://httpbin.org/anything', { dispatcher: proxyAgent })
const json = await res.body.json()
proxyAgent.close()

with global dispatcher

import { fetch, setGlobalDispatcher } from 'undici'
import { NoProxyAgent } from 'undici-noproxy'
const proxyAgent = new NoProxyAgent()

setGlobalDispatcher(proxyAgent)

const res = await fetch(url)
const json = await res.json()

license

MIT licensed

/undici-noproxy/

    Package Sidebar

    Install

    npm i undici-noproxy

    Weekly Downloads

    3

    Version

    1.0.1

    License

    MIT

    Unpacked Size

    7.71 kB

    Total Files

    9

    Last publish

    Collaborators

    • commenthol