File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -52,13 +52,19 @@ export const resolveServerUrl = (options?: {
5252 pathname ?: string | undefined ;
5353 searchParams ?: Record < string , string > | undefined ;
5454} ) : string => {
55- const rawUrl = firstNonEmptyString (
55+ let rawUrl = firstNonEmptyString (
5656 options ?. url ,
5757 window . desktopBridge ?. getWsUrl ( ) ,
5858 import . meta. env . VITE_WS_URL ,
5959 window . location . origin ,
6060 ) ;
6161
62+ // When accessing from a remote host (e.g. mobile), replace localhost in the
63+ // resolved URL with the actual page hostname so the connection reaches the server.
64+ if ( rawUrl . includes ( "localhost" ) && window . location . hostname !== "localhost" ) {
65+ rawUrl = rawUrl . replace ( "localhost" , window . location . hostname ) ;
66+ }
67+
6268 const parsedUrl = new URL ( rawUrl ) ;
6369 if ( options ?. protocol ) {
6470 parsedUrl . protocol = options . protocol ;
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ import { defineConfig } from "vite";
66import pkg from "./package.json" with { type : "json" } ;
77
88const port = Number ( process . env . PORT ?? 5733 ) ;
9+ const host = process . env . T3CODE_HOST ?? "localhost" ;
910const sourcemapEnv = process . env . T3CODE_WEB_SOURCEMAP ?. trim ( ) . toLowerCase ( ) ;
1011
1112const buildSourcemap =
@@ -42,14 +43,9 @@ export default defineConfig({
4243 } ,
4344 server : {
4445 port,
46+ host,
4547 strictPort : true ,
46- hmr : {
47- // Explicit config so Vite's HMR WebSocket connects reliably
48- // inside Electron's BrowserWindow. Vite 8 uses console.debug for
49- // connection logs — enable "Verbose" in DevTools to see them.
50- protocol : "ws" ,
51- host : "localhost" ,
52- } ,
48+ hmr : host === "localhost" ? { protocol : "ws" , host : "localhost" } : { protocol : "ws" } ,
5349 } ,
5450 build : {
5551 outDir : "dist" ,
Original file line number Diff line number Diff line change 1212 " T3CODE_HOME" ,
1313 " T3CODE_AUTH_TOKEN" ,
1414 " T3CODE_DESKTOP_WS_URL" ,
15+ " T3CODE_HOST" ,
1516 " T3CODE_TRACE_MIN_LEVEL" ,
1617 " T3CODE_TRACE_TIMING_ENABLED" ,
1718 " T3CODE_TRACE_FILE" ,
You can’t perform that action at this time.
0 commit comments