If I start the production server I get no errors in chrome console, but after I start the same server but in development mode I get a lot of 404 errors in chrome console probably because the dev server builds some files again. How can I run both in the same time without the dev server changing production server files?
My server script:
const https = require('https')
const fs = require('fs')
const express = require('express')
const { Nuxt, Builder } = require('nuxt')
const app = express()
const host = process.env.HOST || 'localhost' //127.0.0.1
var port = process.env.PORT || 2096
var cluster = require('cluster')
var os = require('os')
var num_processes = os.cpus().length
// Import and Set Nuxt.js options
let config = require('../nuxt.config.js')
config.dev = !(process.env.NODE_ENV === 'production')
if(config.dev) {
num_processes = 1;
}
const options = {
key: fs.readFileSync('/server/ssl/cert.key'),
cert: fs.readFileSync('/server/ssl/cert.crt')
}
if (cluster.isMaster) {
// This stores our workers. We need to keep them to be able to reference
// them based on source IP address. It's also useful for auto-restart,
// for example.
var workers = [];
// Helper function for spawning worker at index 'i'.
var spawn = function(i) {
workers[i] = cluster.fork();
// Optional: Restart worker on exit
workers[i].on('exit', function(code, signal) {
logger.info('Respawning worker.');
spawn(i);
});
};
// Spawn workers.
for (var i = 0; i < num_processes; i++) {
spawn(i);
}
} else {
async function start() {
// Init Nuxt.js
const nuxt = new Nuxt(config)
// Build only in dev mode
if (config.dev) {
const builder = new Builder(nuxt)
await builder.build()
.then(listen)
.catch((error) => {
console.error(error)
process.exit(1)
})
} else {
listen()
}
function listen() {
// Listen the server
https
.createServer(options, nuxt.render)
.listen(port)
console.log('Server listening on https://' + host + ':' + port) // eslint-disable-line no-console
}
}
start()
}
And the chrome console after I start the dev server: