special case for ui mode proxy
This commit is contained in:
parent
62c5fb29d1
commit
2e019eb746
|
|
@ -59,10 +59,13 @@ 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}`);
|
||||
if (options?.dontTouchHost)
|
||||
url.port = '' + port;
|
||||
else
|
||||
url.host = `127.0.0.1:${port}`;
|
||||
if (options?.prefix)
|
||||
url.pathname = url.pathname.replace(options.prefix, '');
|
||||
|
|
@ -79,6 +82,9 @@ 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)
|
||||
url.port = '' + port;
|
||||
else
|
||||
url.host = `127.0.0.1:${port}`;
|
||||
if (options?.prefix)
|
||||
url.pathname = url.pathname.replace(options.prefix, '');
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Reference in a new issue