const { spawn } = require('child_process');
const path = require('path');

const child = spawn(
  'node',
  [path.join(__dirname, 'node_modules', 'next', 'dist', 'bin', 'next'), 'start', '-p', process.env.PORT || 3000],
  { cwd: __dirname, stdio: ['inherit', 'inherit', 'inherit'], env: { ...process.env, NODE_ENV: 'production' } }
);

child.on('exit', (code) => process.exit(code));
