/minimal-http-proxy

A minimal http proxy

Primary LanguageJavaScriptISC LicenseISC

minimal-http-proxy

Build Status js-standard-style npm version Coverage Status

Install

npm install

Usage

npm start [PORT]

  const createProxyServer = require('minimal-http-proxy/server')
  const proxyRequest = require('minimal-http-proxy')
  // request, but trough a proxy
  const proxyServer = createProxyServer(8888)
  const req = proxyRequest({
    // options that will be send to the proxy server
    hostname: 'localhost',
    port: 9090,
    method: 'POST',
    protocol: 'https', // make request over https (optional)
    proxy: {
      // all proxy specific options
      protocol: 'https', // make request over https
      hostname: 'localhost',
      port: 8888,
      method: 'POST'
    }
  }, (res) => {
    var data = ''
    res.on('data', (chunk) => {
      data += chunk
    })
    res.on('end', () => {
      console.log('succes!')
      server.close()
      proxyServer.close()
    })
  })
  req.write('!')
  req.end()

As a query parameter (basic)

proxy.url.com?proxy=http://google.com

As a query parameter with options

proxy.url.com?proxy={ "host": "google.com", "headers": { "lulz": tue } }