electron-vite/electron-vite-react

BrowserWindow.loadfile not seeing route

fagylalt opened this issue · 1 comments

Hey, i am trying to built a simple two window app with React and TS.

The software works great in dev mode, but after building it, it falls apart.

The main window works great, but the second one that i am trying to open with

videoWindow.loadFile(path.join(app.getAppPath(), "/renderer/index.html"), { hash: "#/videos/0" })

gives me this error:

(node:15251) electron: Failed to load URL: file:///opt/alapko-electron/resources/app.asar/renderer/index.html/videos/0 with error: ERR_FILE_NOT_FOUND

this is my router, if it is any help:

    <HashRouter>
      <Routes>
        <Route path="/" element={<MainPage />} />
        <Route path="/video/:id" element={<VideoComponent/>} />
      </Routes>
    </HashRouter>

How should i be loading the second window?

Thank you.

changed to this and it works now.

    videoWindow.loadFile(join(__dirname, "../renderer/index.html"), { hash: "#/video/0" })