Upload file failing with request entity too large

Feature(s) impacted

File upload through forest admin, logging into forest admin when placing app.use(bodyParser.json({ limit: '50mb' })); app.use(bodyParser.urlencoded({ extended: true, limit: '50mb', parameterLimit: 500000 })); app.use(bodyParser.text({ limit: '50mb' }))
before creating the forest admin agent in NestJS

Observed behavior

when the code is in this sequence, i am able to login to forest admin, however i cant upload a file greater than 1 MB.

const app = await NestFactory.create(AppModule, new ExpressAdapter(express()));

  const agent = createAgent({
    authSecret: process.env.FOREST_AUTH_SECRET,
    envSecret: process.env.FOREST_ENV_SECRET,
    isProduction: process.env.NODE_ENV === 'production',
    typingsPath: './typings.ts',
    typingsMaxDepth: 5,
  })
    .addDataSource(createSqlDataSource(process.env.DATABASE_URL))
    .customizeCollection('Player', playerCollections)
    .customizeCollection(
      'PlayerUpcomingTurnamentMapping',
      playerUpcomingTurnamentMappingCollections,
    )
    .customizeCollection('PredefinedLogo', predefinedLogoCollections)
    .customizeCollection('Tournament', tournamentCollections)
    .customizeCollection('LeaguePageVariables', leaguePageVariablesCollections)
    .customizeCollection('League', leagueCollections)
    .mountOnNestJs(app);

  app.use(bodyParser.json({ limit: '50mb' }));
  app.use(bodyParser.urlencoded({ extended: true, limit: '50mb', parameterLimit: 500000 }));
  app.use(bodyParser.text({ limit: '50mb' }))

When the code is placed in this order

const app = await NestFactory.create(AppModule, new ExpressAdapter(express()));

  app.use(bodyParser.json({ limit: '50mb' }));
  app.use(bodyParser.urlencoded({ extended: true, limit: '50mb', parameterLimit: 500000 }));
  app.use(bodyParser.text({ limit: '50mb' }))

  const agent = createAgent({
    authSecret: process.env.FOREST_AUTH_SECRET,
    envSecret: process.env.FOREST_ENV_SECRET,
    isProduction: process.env.NODE_ENV === 'production',
    typingsPath: './typings.ts',
    typingsMaxDepth: 5,
  })
    .addDataSource(createSqlDataSource(process.env.DATABASE_URL))
    .customizeCollection('Player', playerCollections)
    .customizeCollection(
      'PlayerUpcomingTurnamentMapping',
      playerUpcomingTurnamentMappingCollections,
    )
    .customizeCollection('PredefinedLogo', predefinedLogoCollections)
    .customizeCollection('Tournament', tournamentCollections)
    .customizeCollection('LeaguePageVariables', leaguePageVariablesCollections)
    .customizeCollection('League', leagueCollections)
    .mountOnNestJs(app);

I am not even able to login to my forest admin server.

Expected behavior

When placing

 app.use(bodyParser.json({ limit: '50mb' }));
  app.use(bodyParser.urlencoded({ extended: true, limit: '50mb', parameterLimit: 500000 }));
  app.use(bodyParser.text({ limit: '50mb' }))

before creating the forest admin agent, i expect to be able to login and to upload files greated than 1MB

Failure Logs

InternalServerError: stream is not readable
      at readStream (C:\Users\KMF\Documents\Poyesis\fantasy-tennis\fantasy-tennis-backoffice\node_modules\raw-body\index.js:185:17)
      at executor (C:\Users\KMF\Documents\Poyesis\fantasy-tennis\fantasy-tennis-backoffice\node_modules\raw-body\index.js:120:5)
      at new Promise (<anonymous>)
      at getRawBody (C:\Users\KMF\Documents\Poyesis\fantasy-tennis\fantasy-tennis-backoffice\node_modules\raw-body\index.js:119:10)
      at AsyncFunction.module.exports [as json] (C:\Users\KMF\Documents\Poyesis\fantasy-tennis\fantasy-tennis-backoffice\node_modules\co-body\lib\json.js:39:21)
      at parseBody (C:\Users\KMF\Documents\Poyesis\fantasy-tennis\fantasy-tennis-backoffice\node_modules\koa-bodyparser\index.js:99:26)
      at bodyParser (C:\Users\KMF\Documents\Poyesis\fantasy-tennis\fantasy-tennis-backoffice\node_modules\koa-bodyparser\index.js:80:25)
      at dispatch (C:\Users\KMF\Documents\Poyesis\fantasy-tennis\fantasy-tennis-backoffice\node_modules\koa-compose\index.js:42:32)
      at C:\Users\KMF\Documents\Poyesis\fantasy-tennis\fantasy-tennis-backoffice\node_modules\@koa\router\lib\router.js:425:16
      at dispatch (C:\Users\KMF\Documents\Poyesis\fantasy-tennis\fantasy-tennis-backoffice\node_modules\koa-compose\index.js:42:32)
      at cors (C:\Users\KMF\Documents\Poyesis\fantasy-tennis\fantasy-tennis-backoffice\node_modules\@koa\cors\index.js:108:22)
      at dispatch (C:\Users\KMF\Documents\Poyesis\fantasy-tennis\fantasy-tennis-backoffice\node_modules\koa-compose\index.js:42:32)
      at C:\Users\KMF\Documents\Poyesis\fantasy-tennis\fantasy-tennis-backoffice\node_modules\@koa\router\lib\router.js:425:16
      at dispatch (C:\Users\KMF\Documents\Poyesis\fantasy-tennis\fantasy-tennis-backoffice\node_modules\koa-compose\index.js:42:32)
      at C:\Users\KMF\Documents\Poyesis\fantasy-tennis\fantasy-tennis-backoffice\node_modules\koa-compose\index.js:34:12
      at dispatch (C:\Users\KMF\Documents\Poyesis\fantasy-tennis\fantasy-tennis-backoffice\node_modules\@koa\router\lib\router.js:430:31)

Context

  • Project name: Fantasy Tennis
  • Team name: Poyesis
  • Environment name: Production and Development
  • Agent (forest package) name & version:
    "@forestadmin/agent": "^1.8.3", "@forestadmin/datasource-sql": "^1.2.4",
  • Database type: Postgresql

Hi @khaled-faour,

Is it a feature you’re trying to implement right know? or do you think it is a recent regression?
Did you try those changes based on some official documentation you found?

Thanks for your help.

If you have an nginx you will need to update the payload size too with client_max_body_size.
You can take a look at this link if that’s your case.