Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

fix(dashboard): drop hardcoded /ws guid (#40549)

Pavel Feldman08ccdc9a14c2
diff --git a/packages/dashboard/src/index.tsx b/packages/dashboard/src/index.tsx
index 31549512a6..09f4e8112e 100644
--- a/packages/dashboard/src/index.tsx
+++ b/packages/dashboard/src/index.tsx
@@ -28,7 +28,8 @@ import { SplitView } from '@web/components/splitView';
applyTheme();
-const client = DashboardClient.create('/ws');
+const wsGuid = new URLSearchParams(location.search).get('ws') ?? '';
+const client = DashboardClient.create('/' + wsGuid);
const model = new DashboardModel(client);
const pushVisibility = () => model.setVisible(!document.hidden);
diff --git a/packages/playwright-core/src/tools/dashboard/dashboardApp.ts b/packages/playwright-core/src/tools/dashboard/dashboardApp.ts
index f5b699d0dd..5a0634513e 100644
--- a/packages/playwright-core/src/tools/dashboard/dashboardApp.ts
+++ b/packages/playwright-core/src/tools/dashboard/dashboardApp.ts
@@ -83,7 +83,15 @@ async function startDashboardServer(provider: SessionProvider, options: Dashboar
}, submitAnnotation);
connections.add(connection);
return connection;
- }, 'ws');
+ });
+
+ const wsGuid = httpServer.wsGuid()!;
+ httpServer.routePath('/', (_, response) => {
+ response.statusCode = 302;
+ response.setHeader('Location', `/index.html?ws=${wsGuid}`);
+ response.end();
+ return true;
+ });
// HMR: watch builds serve the dashboard through an embedded Vite dev server
// so edits to packages/dashboard/src/* reload live. Release builds always