diff --git a/tests/config/proxy.ts b/tests/config/proxy.ts index cb7663e65f..7efe389b12 100644 --- a/tests/config/proxy.ts +++ b/tests/config/proxy.ts @@ -59,11 +59,11 @@ export class TestProxy { await new Promise(x => this._server.close(x)); } - forwardTo(port: number, options?: { allowConnectRequests?: boolean, prefix?: string, dontTouchHost?: boolean }) { + forwardTo(port: number, options?: { allowConnectRequests?: boolean, prefix?: string, preserveHostname?: boolean }) { this._prependHandler('request', (req: IncomingMessage) => { this.requestUrls.push(req.url); const url = new URL(req.url, `http://${req.headers.host}`); - if (options?.dontTouchHost) + if (options?.preserveHostname) url.port = '' + port; else url.host = `127.0.0.1:${port}`; @@ -82,7 +82,7 @@ export class TestProxy { this._prependHandler('upgrade', (req: IncomingMessage) => { this.wsUrls.push(req.url); const url = new URL(req.url, `http://${req.headers.host}`); - if (options?.dontTouchHost) + if (options?.preserveHostname) url.port = '' + port; else url.host = `127.0.0.1:${port}`; diff --git a/tests/playwright-test/ui-mode-trace.spec.ts b/tests/playwright-test/ui-mode-trace.spec.ts index b354f66b50..b5b584da77 100644 --- a/tests/playwright-test/ui-mode-trace.spec.ts +++ b/tests/playwright-test/ui-mode-trace.spec.ts @@ -340,7 +340,7 @@ test('should show request source context id', async ({ runUITest, server }) => { await expect(page.getByText('api#1')).toBeVisible(); }); -test('should work behind proxy', { annotation: { type: 'issue', description: 'https://github.com/microsoft/playwright/issues/33705' } }, async ({ runUITest, proxyServer }, testInfo) => { +test('should work behind reverse proxy', { annotation: { type: 'issue', description: 'https://github.com/microsoft/playwright/issues/33705' } }, async ({ runUITest, proxyServer: reverseProxy }) => { const { page } = await runUITest({ 'a.test.ts': ` import { test, expect } from '@playwright/test'; @@ -352,9 +352,9 @@ test('should work behind proxy', { annotation: { type: 'issue', description: 'ht `, }); - const origin = new URL(page.url()); - proxyServer.forwardTo(+origin.port, { prefix: '/subdir', dontTouchHost: true }); - await page.goto(`${proxyServer.URL}/subdir${origin.pathname}?${origin.searchParams}`); + const uiModeUrl = new URL(page.url()); + reverseProxy.forwardTo(+uiModeUrl.port, { prefix: '/subdir', preserveHostname: true }); + await page.goto(`${reverseProxy.URL}/subdir${uiModeUrl.pathname}?${uiModeUrl.searchParams}`); await page.getByText('trace test').dblclick();