proxy to both ipv4 and ipv6

This commit is contained in:
Simon Knott 2024-11-29 14:37:38 +01:00
parent 2c7f47a656
commit 0fffa086b5
No known key found for this signature in database
GPG key ID: 8CEDC00028084AEC

View file

@ -63,7 +63,7 @@ export class TestProxy {
this._prependHandler('request', (req: IncomingMessage) => {
this.requestUrls.push(req.url);
const url = new URL(req.url, `http://${req.headers.host}`);
url.port = '' + port;
url.host = `localhost:${port}`;
if (options?.prefix)
url.pathname = url.pathname.replace(options.prefix, '');
req.url = url.toString();
@ -74,12 +74,12 @@ export class TestProxy {
if (kConnectHostsToIgnore.has(req.url))
return;
this.connectHosts.push(req.url);
req.url = `127.0.0.1:${port}`;
req.url = `localhost:${port}`;
});
this._prependHandler('upgrade', (req: IncomingMessage) => {
this.wsUrls.push(req.url);
const url = new URL(req.url, `http://${req.headers.host}`);
url.port = '' + port;
url.host = `localhost:${port}`;
if (options?.prefix)
url.pathname = url.pathname.replace(options.prefix, '');
req.url = url.toString();