File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33 "stage" : " production" ,
44 "productName" : " Phoenix Code" ,
55 "phoenixLoadURL" : " phtauri://localhost/" ,
6+ "trustedElectronDomains" : [" phtauri://localhost/" , " https://phcode.dev/" ],
67 "gaMetricsURL" : " https://phcode.dev/desktop-metrics.html"
78}
Original file line number Diff line number Diff line change @@ -93,14 +93,25 @@ function registerWindowIpcHandlers() {
9393 const prefix = isExtension ? PHOENIX_EXTENSION_WINDOW_PREFIX : PHOENIX_WINDOW_PREFIX ;
9494 const label = getNextLabel ( prefix ) ;
9595
96+ // Resolve relative URLs based on the sender's current URL
97+ let resolvedUrl = url ;
98+ if ( ! url . startsWith ( 'http://' ) && ! url . startsWith ( 'https://' ) && ! url . startsWith ( 'file://' ) ) {
99+ const senderUrl = event . sender . getURL ( ) ;
100+ if ( senderUrl ) {
101+ resolvedUrl = new URL ( url , senderUrl ) . href ;
102+ }
103+ }
104+
105+ console . log ( `Creating window ${ label } with URL ${ resolvedUrl } , isTrustedOrigin=${ isTrustedOrigin ( resolvedUrl ) } ` ) ;
106+
96107 const webPreferences = {
97108 contextIsolation : true ,
98109 nodeIntegration : false ,
99110 sandbox : true
100111 } ;
101112
102- // Only inject preload for Phoenix windows with trusted URLs, not extensions
103- if ( ! isExtension && isTrustedOrigin ( url ) ) {
113+ // Only inject preload for Phoenix windows with trusted URLs
114+ if ( isTrustedOrigin ( resolvedUrl ) ) {
104115 webPreferences . preload = path . join ( __dirname , 'preload.js' ) ;
105116 }
106117
@@ -133,13 +144,16 @@ function registerWindowIpcHandlers() {
133144 webPreferences
134145 } ) ;
135146
147+ // uncomment line below if you want to open dev tools at app start
148+ // win.webContents.openDevTools();
149+
136150 // Track window state for Phoenix windows (not extensions)
137151 if ( ! isExtension ) {
138152 trackWindowState ( win ) ;
139153 }
140154
141155 registerWindow ( win , label ) ;
142- await win . loadURL ( url ) ;
156+ await win . loadURL ( resolvedUrl ) ;
143157
144158 return label ;
145159 } ) ;
Original file line number Diff line number Diff line change @@ -78,7 +78,7 @@ async function createMetricsWindow() {
7878 } ) ;
7979 metricsWindow . loadURL ( gaMetricsURL ) ;
8080 // uncomment line below if you want to open dev tools at app start
81- metricsWindow . webContents . openDevTools ( ) ;
81+ // metricsWindow.webContents.openDevTools();
8282}
8383
8484async function createWindow ( ) {
You can’t perform that action at this time.
0 commit comments