fix(ui): add proper CORS header for loading traces in HMR mode (#34558)
This commit is contained in:
parent
833c729eb0
commit
5afb04b62e
|
|
@ -67,6 +67,10 @@ export async function startTraceViewerServer(options?: TraceViewerServerOptions)
|
||||||
server.routePrefix('/trace', (request, response) => {
|
server.routePrefix('/trace', (request, response) => {
|
||||||
const url = new URL('http://localhost' + request.url!);
|
const url = new URL('http://localhost' + request.url!);
|
||||||
const relativePath = url.pathname.slice('/trace'.length);
|
const relativePath = url.pathname.slice('/trace'.length);
|
||||||
|
if (process.env.PW_HMR) {
|
||||||
|
// When running in Vite HMR mode, port is hardcoded in build.js
|
||||||
|
response.appendHeader('Access-Control-Allow-Origin', 'http://localhost:44223');
|
||||||
|
}
|
||||||
if (relativePath.endsWith('/stall.js'))
|
if (relativePath.endsWith('/stall.js'))
|
||||||
return true;
|
return true;
|
||||||
if (relativePath.startsWith('/file')) {
|
if (relativePath.startsWith('/file')) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue