Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

superagent-proxy

TooTallNate1.1mMIT3.0.0TypeScript support: definitely-typed

Request#proxy(uri) superagent extension

superagent, http, https, proxy, socks

readme

superagent-proxy

Request#proxy(uri) superagent extension

This module extends superagent's Request class with a .proxy(uri) function. This allows you to proxy the HTTP request through a proxy of some kind.

It is backed by the proxy-agent module, so see its README for more details.

Installation

Install with npm:

$ npm install superagent-proxy

Example

var request = require('superagent');

// extend with Request#proxy()
require('superagent-proxy')(request);

// HTTP, HTTPS, or SOCKS proxy to use
var proxy = process.env.http_proxy || 'http://168.63.43.102:3128';

request
  .get(process.argv[2] || 'https://encrypted.google.com/')
  .proxy(proxy)
  .end(onresponse);

function onresponse (err, res) {
  if (err) {
    console.log(err);
  } else {
    console.log(res.status, res.headers);
    console.log(res.body);
  }
}

License

(The MIT License)

Copyright (c) 2013 Nathan Rajlich <nathan@tootallnate.net>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

changelog

2.0.0 / 2018-07-11

  • Upgrade "proxy-agent" to remove deprecation warning and enable socks v2
  • drop support for Node < 6

1.0.3 / 2018-02-12

  • [757b09f485] - Upgrading debug dependency to avoid ReDoS (#26) (Adrián Estrada)
  • [17fd826650] - rename History.md to CHANGELOG.md (Nathan Rajlich)
  • [050b80b237] - fix date (Nathan Rajlich)

1.0.2 / 2016-11-21

  • [915a4b0ee9] - Update to use superagent 3 (#23, Matt Blair)

1.0.1 / 2016-06-22

  • package: allow "superagent" v2
  • fixed example (#15, @reedrosenbluth)

1.0.0 / 2015-07-15

  • bumping to v1.0.0 for stricter defined semver semantics

0.4.0 / 2015-07-15

  • update to "proxy-agent" v2 API
  • use %o debug() formatter

0.3.2 / 2015-05-18

  • package: update "debug" to v2.2.0
  • package: still limit "superagent" to < v2
  • package: support superagent >= 1.0 (#14, @Jxck)

0.3.1 / 2014-08-21

  • package: looser "superagnet" peerDependency version

0.3.0 / 2014-01-13

  • index: fix the redirect http -> https scenario
  • index: use debug component
  • package: update "proxy-agent" to v1

0.2.0 / 2013-11-20

  • index: use "proxy-agent"

0.1.0 / 2013-11-16

  • index: implement an LRU cache to lower the creation of http.Agent instances
  • index: include the ":" when generating the cache URI
  • index: add support for calling the proxy function directly
  • index: cleanup and refactor to allow for an opts object to be used
  • test: add some basic tests for the .proxy() function

0.0.2 / 2013-11-15

  • package: add "superagent" to devDependencies
  • only invoke url.parse() when the proxy is a string
  • README++

0.0.1 / 2013-07-11

  • Initial release, currently supports:
    • http:
    • https:
    • socks: (version 4a)