Skip to content

Instantly share code, notes, and snippets.

@TWinsnes
Created August 23, 2022 07:14
Show Gist options
  • Save TWinsnes/54d9b7f2f9383509c051e0f6a24b43df to your computer and use it in GitHub Desktop.
Save TWinsnes/54d9b7f2f9383509c051e0f6a24b43df to your computer and use it in GitHub Desktop.
Quick nodejs Proxy for debugging https requests
// Update the target to be the taget url you are hitting
//
// run this standalone and in your app send traffic to localhost:8000
var http = require('http'),
httpProxy = require('http-proxy');
const proxy = httpProxy.createProxyServer({
target: 'https://target.url.com',
secure: false
})
proxy.listen(8000)
proxy.on('proxyReq', async function (proxyReq, req, res) {
const buffers = []
for await (const chunk of req) {
buffers.push(chunk)
}
const data = Buffer.concat(buffers).toString()
console.log(data)
console.log(JSON.stringify(proxyReq.getHeaders()))
console.log(`${proxyReq.protocol}//${proxyReq.host}${proxyReq.path}`)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment