aws-amplify / aws-amplify/amplify-hosting

Set serverActionsBodySizeLimit in next.config.js not working

Open
#3,784 0 comments 0 reactions 0 assignees View on GitHub
pending-triage
Dominant language
Dockerfile
Stars
481
Forks
123
PR merge metrics
No merged PRs in 30d

Description

### Before opening, please confirm:

- [X] I have checked to see if my question is addressed in the [FAQ](https://github.com/aws-amplify/amplify-hosting/blob/master/FAQ.md).
- [X] I have [searched for duplicate or closed issues](https://github.com/aws-amplify/amplify-hosting/issues?q=is%3Aissue+).
- [X] I have read the guide for [submitting bug reports](https://github.com/aws-amplify/amplify-hosting/blob/master/CONTRIBUTING.md).
- [X] I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
- [X] I have removed any sensitive information from my code snippets and submission.

### App Id

d28kmmcmrclnus

### AWS Region

eu-west-1

### Amplify Hosting feature

SSR

### Frontend framework

Next.js

### Next.js version

13.5.6

### Next.js router

App Router

### Describe the bug

When working with server actions, a commonly encountered issue is receiving an error 413 if the returned data surpasses the default 1MB limit. To address this problem, one workaround is to include the serverActionsBodySizeLimit configuration in the next.config.js file. However, the issue persists even after implementing this configuration.

### Expected behavior

Enable successful retrieval of data larger than 1MB over server actions, by adjusting the serverActionsBodySizeLimit configuration.

### Reproduction steps

1. Set up a Next.js project with server actions that use fetch to retrieve data.
2. Trigger a request to the server action endpoint that is expected to return data larger than the default 1MB limit.
3. Observe if the server responds with the error 413, indicating that the request body has exceeded the allowed size.
4. Modify the limit of 1mb in next.config.js using
```
experimental: {
serverActions: true,
serverActionsBodySizeLimit: '100mb'
}
```
5. Check if the 413 error is gone. (it should persist)

### Build Settings

```yaml
version: 1
frontend:
phases:
preBuild:
commands:
- corepack enable
- yarn set version 3.x
- yarn install
build:
commands:
- yarn run build
- echo "NEXTAUTH_SECRET=$NEXTAUTH_SECRET" >> .env
- echo "NEXTAUTH_URL=$NEXTAUTH_URL" >> .env
- echo "API_URL=$API_URL" >> .env
artifacts:
baseDirectory: .next
files:
- '**/*'
cache:
paths:
- node_modules/**/*
```

### Log output

```
Failed to load resource: the server responded with a status of 413 () |
```

### Additional information

_No response_

Contributor guide

Open the contributing guide

Research direction

Reproduce the reported 413 with Next.js 13.5.6, the App Router, and the experimental serverActionsBodySizeLimit setting in next.config.js. Start by comparing local behavior with the Amplify Hosting SSR build settings shown in the issue. Done means identifying why the configured limit is not applied in Amplify Hosting and documenting or fixing the deployment behavior so requests over 1MB succeed.

Written by the indexing model from the issue text.

Assessment

Tech stack
next.js
Domain
cloud, devops
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.