@ -24,6 +24,46 @@ function createWindow() {
} ,
} ,
} ) ;
} ) ;
// Always open DevTools for now
mainWindow . webContents . openDevTools ( ) ;
// Intercept requests to fix asset paths
mainWindow . webContents . session . webRequest . onBeforeRequest (
{
urls : [
"file://*/*/assets/*" ,
"file://*/assets/*" ,
"file:///assets/*" , // Catch absolute paths
"<all_urls>" , // Catch all URLs as a fallback
] ,
} ,
( details , callback ) => {
let url = details . url ;
console . log ( "Intercepting asset request:" , url ) ;
// Handle paths that don't start with file://
if ( ! url . startsWith ( "file://" ) && url . includes ( "/assets/" ) ) {
url = ` file:// ${ path . join ( __ dirname , "www" , url ) } ` ;
}
// Handle absolute paths starting with /assets/
if ( url . includes ( "/assets/" ) && ! url . includes ( "/www/assets/" ) ) {
const baseDir = url . includes ( "dist-electron" )
? url . substring (
0 ,
url . indexOf ( "/dist-electron" ) + "/dist-electron" . length ,
)
: ` file:// ${ __ dirname } ` ;
const assetPath = url . split ( "/assets/" ) [ 1 ] ;
const newUrl = ` ${ baseDir } /www/assets/ ${ assetPath } ` ;
console . log ( "Redirecting to:" , newUrl ) ;
callback ( { redirectURL : newUrl } ) ;
return ;
}
callback ( { } ) ; // No redirect for other URLs
} ,
) ;
// Debug info
// Debug info
console . log ( "Debug Info:" ) ;
console . log ( "Debug Info:" ) ;
console . log ( "Running in dev mode:" , isDev ) ;
console . log ( "Running in dev mode:" , isDev ) ;
@ -34,6 +74,7 @@ function createWindow() {
console . log ( "process.cwd():" , process . cwd ( ) ) ;
console . log ( "process.cwd():" , process . cwd ( ) ) ;
const indexPath = path . join ( __ dirname , "www" , "index.html" ) ;
const indexPath = path . join ( __ dirname , "www" , "index.html" ) ;
console . log ( "Loading index from:" , indexPath ) ;
console . log ( "www path:" , path . join ( __ dirname , "www" ) ) ;
console . log ( "www path:" , path . join ( __ dirname , "www" ) ) ;
console . log ( "www assets path:" , path . join ( __ dirname , "www" , "assets" ) ) ;
console . log ( "www assets path:" , path . join ( __ dirname , "www" , "assets" ) ) ;