Only start ClientRouter for production

This commit is contained in:
advplyr 2023-05-01 17:12:17 -05:00
parent 634167aea6
commit 57994ffb5b
3 changed files with 9 additions and 6 deletions

View file

@ -4,7 +4,7 @@ global.appRoot = __dirname
const isDev = process.env.NODE_ENV !== 'production'
if (isDev) {
const devEnv = require('./dev').config
process.env.NODE_ENV = 'development'
process.env.NODE_ENV = devEnv.Env || 'development'
if (devEnv.Port) process.env.PORT = devEnv.Port
if (devEnv.ConfigPath) process.env.CONFIG_PATH = devEnv.ConfigPath
if (devEnv.MetadataPath) process.env.METADATA_PATH = devEnv.MetadataPath

View file

@ -139,7 +139,9 @@ class Server {
async start() {
Logger.info('=== Starting Server ===')
await this.init()
if (process.env.NODE_ENV !== 'development') {
this.clientRouter.start()
}
const app = express()
const router = express.Router()

View file

@ -13,7 +13,6 @@ class ClientRouter {
this.client = null
this.router = express()
this.router.disable('x-powered-by')
this.init()
}
init() {
@ -24,6 +23,8 @@ class ClientRouter {
}
start() {
this.init()
const clientDir = Path.join(this.appRoot, '/client')
const clientPath = Path.join(clientDir, '/node_modules/@nuxt/cli/bin/nuxt-cli.js')
this.client = childProcess.fork(clientPath, ["start"], { cwd: clientDir, stdio: 'pipe' })