Open
Description

Hi, I have this error when using the proxy.
My code:
import { Proxy } from "http-mitm-proxy";
// or using import/module (package.json -> "type": "module")
// import { Proxy } from "http-mitm-proxy";
const proxy = new Proxy();
proxy.onError(function(ctx, err) {
console.error('proxy error:', err);
});
proxy.onRequest(function(ctx, callback) {
console.log('proxying:', ctx.clientToProxyRequest.url);
//if (ctx.clientToProxyRequest.headers.host == 'www.google.com'
// && ctx.clientToProxyRequest.url?.indexOf('/search') == 0) {
// ctx.use(Proxy.gunzip);
//
// ctx.onResponseData(function(ctx, chunk, callback) {
// chunk = Buffer.from(chunk.toString().replace(/<h3.*?<\/h3>/g, '<h3>Pwned!</h3>'));
// return callback(null, chunk);
// });
//}
return callback();
});
console.log('begin listening on 8081')
proxy.listen({host: "localhost", port: 8081, sslCaDir: require('path').join(__dirname, '.http-mitm-proxy'), });`
Metadata
Metadata
Assignees
Labels
No labels