@@ -17,6 +17,8 @@ import { usePrevious } from '@/utils';
17
17
18
18
import { getClickhouseClient } from './clickhouse' ;
19
19
import { useSource } from './source' ;
20
+ import { IS_LOCAL_MODE } from './config' ;
21
+ import { getLocalConnections } from './connection' ;
20
22
21
23
export type Session = {
22
24
errorCount : string ;
@@ -370,6 +372,19 @@ export function useRRWebEventStream(
370
372
metadata ,
371
373
) ;
372
374
375
+ let hostname : string | undefined ;
376
+ let pathname : string | undefined ;
377
+ let username : string | undefined ;
378
+ let password : string | undefined ;
379
+ if ( IS_LOCAL_MODE ) {
380
+ const localConnections = getLocalConnections ( ) ;
381
+ const fullUrl = new URL ( localConnections [ 0 ] . host ) ;
382
+ hostname = fullUrl . hostname ;
383
+ pathname = fullUrl . pathname ;
384
+ username = localConnections [ 0 ] . username ;
385
+ password = localConnections [ 0 ] . password ;
386
+ }
387
+
373
388
// TODO: Change ClickhouseClient class to use this under the hood,
374
389
// and refactor this to use ClickhouseClient.query
375
390
const clickhouseClient = createClient ( {
@@ -378,14 +393,18 @@ export function useRRWebEventStream(
378
393
wait_end_of_query : 0 ,
379
394
cancel_http_readonly_queries_on_client_close : 1 ,
380
395
} ,
381
- http_headers : {
382
- 'x-hyperdx-connection-id' : source . connection ,
383
- } ,
384
- url : window . location . origin ,
385
- pathname : '/api/clickhouse-proxy' ,
396
+ http_headers : ! IS_LOCAL_MODE
397
+ ? {
398
+ 'x-hyperdx-connection-id' : source . connection ,
399
+ }
400
+ : undefined ,
401
+ url : hostname ?? window . location . origin ,
402
+ pathname : pathname ?? '/api/clickhouse-proxy' ,
386
403
compression : {
387
404
response : true ,
388
405
} ,
406
+ username,
407
+ password,
389
408
} ) ;
390
409
391
410
const fetchPromise = ( async ( ) => {
0 commit comments