special case for ui mode proxy
This commit is contained in:
parent
62c5fb29d1
commit
2e019eb746
|
|
@ -59,11 +59,14 @@ export class TestProxy {
|
||||||
await new Promise(x => this._server.close(x));
|
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._prependHandler('request', (req: IncomingMessage) => {
|
||||||
this.requestUrls.push(req.url);
|
this.requestUrls.push(req.url);
|
||||||
const url = new URL(req.url, `http://${req.headers.host}`);
|
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)
|
if (options?.prefix)
|
||||||
url.pathname = url.pathname.replace(options.prefix, '');
|
url.pathname = url.pathname.replace(options.prefix, '');
|
||||||
req.url = url.toString();
|
req.url = url.toString();
|
||||||
|
|
@ -79,7 +82,10 @@ export class TestProxy {
|
||||||
this._prependHandler('upgrade', (req: IncomingMessage) => {
|
this._prependHandler('upgrade', (req: IncomingMessage) => {
|
||||||
this.wsUrls.push(req.url);
|
this.wsUrls.push(req.url);
|
||||||
const url = new URL(req.url, `http://${req.headers.host}`);
|
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)
|
if (options?.prefix)
|
||||||
url.pathname = url.pathname.replace(options.prefix, '');
|
url.pathname = url.pathname.replace(options.prefix, '');
|
||||||
req.url = url.toString();
|
req.url = url.toString();
|
||||||
|
|
|
||||||
|
|
@ -353,7 +353,7 @@ test('should work behind proxy', { annotation: { type: 'issue', description: 'ht
|
||||||
});
|
});
|
||||||
|
|
||||||
const origin = new URL(page.url());
|
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.goto(`${proxyServer.URL}/subdir${origin.pathname}?${origin.searchParams}`);
|
||||||
|
|
||||||
await page.getByText('trace test').dblclick();
|
await page.getByText('trace test').dblclick();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue