Hi @Iheb Jandoubi To increase the request size limit for your Node.js Express application deployed on Azure App Service, you'll need to configure the server.maxRequestSize
option in your Express app.
First, locate the part of your code where you initialize the Express app. It usually looks like this:
const express = require('express');
const app = express();
After that, you can set the server.maxRequestSize
option to a larger value. For example, to set the limit to 100MB (104857600 bytes), you can add the following code:
// Set maximum request size to 100MB
app.use(express.json({ limit: '104857600' }));
app.use(express.urlencoded({ limit: '104857600', extended: true }));
This will set the request size limit for both JSON and URL-encoded payloads to 100MB.
If you're using a different method to parse the request body, you'll need to adjust the code accordingly. For example, if you're using the multer
middleware for file uploads, you can set the limits.fileSize
option:
const multer = require('multer');
const upload = multer({
limits: {
fileSize: 104857600 // 100MB
}
});
After making these changes in your code, redeploy your application to Azure App Service, and it should allow larger file uploads.
Additionally, you can also increase the request size limit in Azure App Service by setting the web.maxRequestBodySizeInKb
app setting in the Azure Portal or using the Azure CLI. This setting is applied at the server level and overrides any application-level settings.
For example, to set the maximum request body size to 100MB (102400KB) using the Azure CLI, you can run the following command:
az webapp config set --name <app-name> --resource-group <resource-group-name> --web-server-max-request-body-size-in-kb 102400
you should replace <app-name>
and <resource-group-name>
with the appropriate values for your Azure App Service.
By adjusting both the application-level and server-level settings, you should be able to upload larger files to your Node.js Express application deployed on Azure App Service.
Best,
Grace