Skip to content

Commit

Permalink
fix: nextApp fix in main.js
Browse files Browse the repository at this point in the history
  • Loading branch information
mohandast52 committed Oct 2, 2024
1 parent a471109 commit 309d9ab
Showing 1 changed file with 16 additions and 17 deletions.
33 changes: 16 additions & 17 deletions electron/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ let tray = null;

let operateDaemon, operateDaemonPid, nextAppProcess, nextAppProcessPid;

// @ts-ignore - Workaround for the missing type definitions
const nextApp = next({
dev: false,
dir: path.join(__dirname),
});

const getActiveWindow = () => splashWindow ?? mainWindow;

function showNotification(title, body) {
Expand Down Expand Up @@ -305,29 +311,22 @@ async function launchDaemonDev() {
}

async function launchNextApp() {
const nextApp = next({
dev: false,
dir: path.join(__dirname),
port: appConfig.ports.prod.next,
env: {
GNOSIS_RPC:
process.env.NODE_ENV === 'production'
? process.env.FORK_URL
: process.env.DEV_RPC,
NEXT_PUBLIC_BACKEND_PORT:
process.env.NODE_ENV === 'production'
? appConfig.ports.prod.operate
: appConfig.ports.dev.operate,
},
});
logger.electron('Launching Next App');

logger.electron('Preparing Next App');
await nextApp.prepare();

logger.electron('Getting Next App Handler');
const handle = nextApp.getRequestHandler();

logger.electron('Creating Next App Server');
const server = http.createServer((req, res) => {
handle(req, res); // Handle requests using the Next.js request handler
});
server.listen(appConfig.ports.prod.next, (err) => {
if (err) throw err;

logger.electron('Listening on Next App Server');
server.listen(appConfig.ports.prod.next, (test) => {
logger.electron(test);
logger.next(
`> Next server running on http://localhost:${appConfig.ports.prod.next}`,
);
Expand Down

0 comments on commit 309d9ab

Please sign in to comment.