Skip to content

App router Increase body size limit Api routes #57501

@Biratus

Description

@Biratus

Link to the code that reproduces this issue

https://codesandbox.io/s/next-with-api-forked-6cs9k8?file=/pages/api/test.js

To Reproduce

I am reopening the issue #52457 because the final comment : #52457 (comment) was not answered.

Use the link https://codesandbox.io/s/next-with-api-forked-6cs9k8?file=/pages/api/test.js to reproduce

Current vs. Expected behavior

In the pages router we can modify the body size limit with:

export const config = {
  api: {
    bodyParser: {
      sizeLimit: "5mb",
    },
  },
};

However there is no equivalent in the App Router. It does work in development mode but fails during the build

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

Operating System:
  Platform: linux
  Arch: x64
  Version: #97~20.04.1-Ubuntu SMP Thu Oct 5 08:25:28 UTC 2023
Binaries:
  Node: 16.16.0
  npm: 8.11.0
  Yarn: 1.22.19
  pnpm: N/A
Relevant Packages:
  next: 13.5.6
  eslint-config-next: 13.4.7
  react: 18.2.0
  react-dom: 18.2.0
  typescript: 5.1.6
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

App Router

Additional context

To increase the body limit, do we need to define the api route the old way on the page router (so we can use export config) or is there an alternative in the app router ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIssue was opened via the bug report template.locked

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions