address feedback
This commit is contained in:
parent
41aeb0ee56
commit
9087dd7af6
|
|
@ -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}`;
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue