chore(trace viewer): support HMR

This commit is contained in:
Simon Knott 2024-11-14 15:52:24 +01:00
parent 445ff73c6e
commit 67e77d0139
No known key found for this signature in database
GPG key ID: 8CEDC00028084AEC
2 changed files with 7 additions and 3 deletions

View file

@ -127,7 +127,11 @@ export async function installRootRedirect(server: HttpServer, traceUrls: string[
params.set('server', server.urlPrefix('precise'));
const urlPath = `./trace/${options.webApp || 'index.html'}?${params.toString()}`;
let baseUrl = '.';
if (process.env.PW_HMR)
baseUrl = 'http://localhost:44223'; // port is hardcoded in build.js
const urlPath = `${baseUrl}/trace/${options.webApp || 'index.html'}?${params.toString()}`;
server.routePath('/', (_, response) => {
response.statusCode = 302;
response.setHeader('Location', urlPath);

View file

@ -48,8 +48,8 @@ const xtermDataSource: XtermDataSource = {
const searchParams = new URLSearchParams(window.location.search);
const guid = searchParams.get('ws');
const wsURL = new URL(`../${guid}`, window.location.toString());
wsURL.protocol = (window.location.protocol === 'https:' ? 'wss:' : 'ws:');
const wsURL = new URL(`/${guid}`, searchParams.get('server') ?? window.location.toString());
wsURL.protocol = (wsURL.protocol === 'https:' ? 'wss:' : 'ws:');
const queryParams = {
args: searchParams.getAll('arg'),
grep: searchParams.get('grep') || undefined,