Skip to content

Error host doubled #310

Open
Open
@BenjaminKoskas

Description

@BenjaminKoskas
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'), });`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions