node-debugging-proxy
A simple HTTP proxy that proxies HTTP and HTTPS requests transparently. Useful for debugging that your application works correctly with proxies.
Installation
npm i -g @cypress/debugging-proxy
## or, if you prefer yarn
yarn global add @cypress/debugging-proxy
Usage (as a standalone server)
Start the proxy on port 1337
debugging-proxy
Use a custom port
PORT=1234 debugging-proxy
Show logs of all requests
DEBUG=proxy debugging-proxy
Require HTTP Basic Auth for proxy access
PROXY_USER=some-username PROXY_PASS=some-password debugging-proxy
Spawn an HTTPS proxy using a custom key and cert
HTTPS_KEY=/path/to/key.key HTTPS_CERT=/path/to/cert.pem debugging-proxy
Usage (as a module, in a test)
const debugProxy = require('@cypress/debugging-proxy')
const proxy = new debugProxy({
auth: {
username: 'foo',
password: 'bar'
},
keepRequests: false,
https: {
key: fs.readFileSync('my-key.pem'),
cert: fs.readFileSync('my-cert.pem')
}
})
spy(proxy.proxyRequestToUrl)
spy(proxy.proxySslConnectionToDomain)
proxy.start(3000).then(() => {
expect(proxy.proxyRequestToUrl).to.be.calledWith('http://google.com')
expect(proxy.proxySslConnectionToDomain).to.be.calledWith('google.com')
expect(proxy.getRequests().find(incomingMessage => incomingMessage.ssl === false)).to.exist
proxy.stop().then(() => {
console.log('All done!')
})
})