diff --git a/tests/config/proxy.ts b/tests/config/proxy.ts index 13c03cccb4..cb7663e65f 100644 --- a/tests/config/proxy.ts +++ b/tests/config/proxy.ts @@ -59,11 +59,14 @@ export class TestProxy { await new Promise(x => this._server.close(x)); } - forwardTo(port: number, options?: { allowConnectRequests?: boolean, prefix?: string }) { + forwardTo(port: number, options?: { allowConnectRequests?: boolean, prefix?: string, dontTouchHost?: boolean }) { this._prependHandler('request', (req: IncomingMessage) => { this.requestUrls.push(req.url); const url = new URL(req.url, `http://${req.headers.host}`); - url.host = `127.0.0.1:${port}`; + if (options?.dontTouchHost) + url.port = '' + port; + else + url.host = `127.0.0.1:${port}`; if (options?.prefix) url.pathname = url.pathname.replace(options.prefix, ''); req.url = url.toString(); @@ -79,7 +82,10 @@ export class TestProxy { this._prependHandler('upgrade', (req: IncomingMessage) => { this.wsUrls.push(req.url); const url = new URL(req.url, `http://${req.headers.host}`); - url.host = `127.0.0.1:${port}`; + if (options?.dontTouchHost) + url.port = '' + port; + else + url.host = `127.0.0.1:${port}`; if (options?.prefix) url.pathname = url.pathname.replace(options.prefix, ''); req.url = url.toString(); diff --git a/tests/playwright-test/ui-mode-trace.spec.ts b/tests/playwright-test/ui-mode-trace.spec.ts index b1a2904807..b354f66b50 100644 --- a/tests/playwright-test/ui-mode-trace.spec.ts +++ b/tests/playwright-test/ui-mode-trace.spec.ts @@ -353,7 +353,7 @@ test('should work behind proxy', { annotation: { type: 'issue', description: 'ht }); const origin = new URL(page.url()); - proxyServer.forwardTo(+origin.port, { prefix: '/subdir' }); + proxyServer.forwardTo(+origin.port, { prefix: '/subdir', dontTouchHost: true }); await page.goto(`${proxyServer.URL}/subdir${origin.pathname}?${origin.searchParams}`); await page.getByText('trace test').dblclick();