-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrun-production.js
More file actions
29 lines (24 loc) · 1.06 KB
/
Copy pathrun-production.js
File metadata and controls
29 lines (24 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// This script runs the production build with required environment variables
const { spawn } = require('child_process');
const path = require('path');
// Set all required environment variables
process.env.NEXTAUTH_SECRET = 'a_very_long_secret_value_for_nextauth';
process.env.NEXTAUTH_URL = 'http://localhost:3000';
process.env.NEXT_PUBLIC_APP_URL = 'http://localhost:3000';
process.env.AUTH_TRUST_HOST = 'true';
// Log the server start
console.log('Starting production server with environment variables:');
console.log('- NEXTAUTH_URL:', process.env.NEXTAUTH_URL);
console.log('- NEXT_PUBLIC_APP_URL:', process.env.NEXT_PUBLIC_APP_URL);
console.log('- AUTH_TRUST_HOST:', process.env.AUTH_TRUST_HOST);
// Path to the standalone server.js
const serverPath = path.join(__dirname, '.next', 'standalone', 'server.js');
// Spawn the server process with the environment variables
const server = spawn('node', [serverPath], {
stdio: 'inherit',
env: process.env
});
// Handle process exit
server.on('close', (code) => {
console.log(`Server process exited with code ${code}`);
});