Do not use Nodemon in the production environment as it is intended for development purposes only.
When running the backend using the Process Manager (PM2), ensure that all folder names are included as values of the ignore_path property in the ecosystem.config.js file.
module.exports = {
apps: [
{
name: "jash-backend",
exec_mode: "cluster",
instances: "max",
script: "./index.js",
autorestart: true,
args: "start",
exp_backoff_restart_delay: 100,
watch: true, // Still watch files, but exclude specific directories
ignore_watch: ["node_modules", "uploads"], // Add the directories to ignore here
max_memory_restart: "400M",
},
],
};To resolve the "413 Request Entity Too Large" issue, take the following actions:
- Add the
client_max_body_sizedirective to the NGINX configuration file:
nginx http { client_max_body_size 50M; # Adjust to the desired limit }
- Test the NGINX configuration with the following command:
sudo nginx -t- Restart NGINX to apply the changes:
sudo systemctl restart nginx- Update the
LimitRequestBodydirective in your Apache configuration file, typically located at/etc/apache2/apache2.confor within a virtual host configuration:
apache <Directory "/var/www/html"> LimitRequestBody 52428800 # 50MB in bytes </Directory>
- Restart Apache to implement the changes:
bash sudo systemctl restart apache2