From d353dff8b11286ba89df6f4c55eb02fe946df601 Mon Sep 17 00:00:00 2001 From: atrincas Date: Tue, 7 Jan 2025 12:09:55 +0100 Subject: [PATCH] fix: Next.js server startup process --- client/index.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/client/index.js b/client/index.js index 06727665..7c43c4f5 100644 --- a/client/index.js +++ b/client/index.js @@ -1,9 +1,16 @@ +const { spawn } = require('child_process'); const path = require('path'); - const nextPath = path.join(__dirname, 'node_modules', '.bin', 'next'); -process.argv.length = 1; -process.argv.push(nextPath, 'start'); +const nextProcess = spawn(nextPath, ['start'], { + stdio: 'inherit', +}); + +nextProcess.on('error', (err) => { + console.error('Failed to start Next.js:', err); + process.exit(1); +}); -// eslint-disable-next-line import/no-dynamic-require -require(nextPath); +nextProcess.on('exit', (code) => { + process.exit(code); +});