File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -53,6 +53,39 @@ Based on that a GUI is generated to test the API directly from browser:
5353
5454We currently use [ pm2] ( https://pm2.keymetrics.io/ ) to start the project in production
5555
56+ ### Important – restart PM2 after deploying backend changes
57+
58+ PM2 keeps the old Node.js process running until explicitly restarted.
59+ After pulling new backend code (e.g. body-parser limit changes), ** always**
60+ reload or restart the PM2 process:
61+
62+ ``` shell
63+ pm2 reload pm2-process-cluster.json # zero-downtime reload (preferred)
64+ # or
65+ pm2 restart pm2-process-cluster.json # hard restart
66+ ```
67+
68+ > ** Example:** The Express body-parser is configured to accept up to ** 6 MB** JSON
69+ > payloads (` app.js ` ). If you deploy this change but forget to restart PM2,
70+ > production still runs with the old default limit (100 KB) and larger requests
71+ > (e.g. Jupyter notebook uploads) will fail with ** 413 Request Entity Too Large** .
72+
73+ ### Nginx reverse proxy – large request bodies
74+
75+ If nginx sits in front of the API, its default ` client_max_body_size ` of ** 1 MB**
76+ can also reject large requests before they reach Node.js. Add the following to the
77+ nginx ` server ` or ` location ` block that proxies to the API:
78+
79+ ``` nginx
80+ client_max_body_size 6m;
81+ ```
82+
83+ Then reload nginx:
84+
85+ ``` shell
86+ sudo nginx -t && sudo systemctl reload nginx
87+ ```
88+
5689Undo local changes if needed:
5790
5891```
Original file line number Diff line number Diff line change @@ -76,8 +76,12 @@ setUpLogging();
7676
7777app . use ( '/api/docs' , swaggerUi . serve , swaggerUi . setup ( swaggerDocument ) ) ; //swagger docs are not protected
7878
79- app . use ( bodyParser . json ( { limit : '6mb' } ) ) ; // raised from default 100kb to support Jupyter notebook uploads
80- app . use ( bodyParser . urlencoded ( { extended : false } ) ) ;
79+ // Raised from the default 100kb to support Jupyter notebook uploads (up to 5 MB).
80+ // IMPORTANT: if a reverse proxy (e.g. nginx) sits in front of this server, its own
81+ // body-size limit must also be raised. For nginx add to server/location block:
82+ // client_max_body_size 6m;
83+ app . use ( bodyParser . json ( { limit : '6mb' } ) ) ;
84+ app . use ( bodyParser . urlencoded ( { limit : '6mb' , extended : false } ) ) ;
8185
8286app . set ( 'trust proxy' , 'loopback' ) ;
8387
You can’t perform that action at this time.
0 commit comments