Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error host doubled #310

Open
BenjaminKoskas opened this issue Sep 17, 2024 · 0 comments
Open

Error host doubled #310

BenjaminKoskas opened this issue Sep 17, 2024 · 0 comments

Comments

@BenjaminKoskas
Copy link

Screenshot 2024-09-17 at 15 17 20

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'), });`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant