Body exceeded 1mb limit error in NextJS #2590
-
Provide environment information
Describe the bugI need to write/read larger PNG Base64 strings to the database (3x 1MB). It works as long as the total file size of all three images is less than 700 KB. When the images are larger I get this error:
Just using prisma without trpc is working as well! To reproduce// Generate Base64:
const convertBase64 = (file: any) => {
return new Promise((resolve, reject) => {
const fileReader = new FileReader();
fileReader.readAsDataURL(file)
fileReader.onload = async () => resolve(fileReader.result)
fileReader.onerror = (error) => reject(error)
})
}
export const handleFileRead = (Event: React.ChangeEvent<HTMLInputElement>) => {
const { files } = Event.target;
const file = files?.[0]
return convertBase64(file)
} Additional informationNo response 👨👧👦 Contributing
|
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 2 replies
-
https://stackoverflow.com/questions/68574254/body-exceeded-1mb-limit-error-in-next-js-api-route |
Beta Was this translation helpful? Give feedback.
-
I'm using export const config = {
api: {
bodyParser: {
sizeLimit: '100mb',
},
responseLimit: '100mb',
}
} |
Beta Was this translation helpful? Give feedback.
-
Hey ! I'm having the same problem, so I've defined the required api route configuration in the [trpc] route, but I'd like to adjust this limit according to the routers and procedures. Has anyone ever done something like this? |
Beta Was this translation helpful? Give feedback.
-
For anybody else facing this issue, I was able to solve it using @lobotomoe's solution. My project structure was set up using t3 and the only change required is in
|
Beta Was this translation helpful? Give feedback.
I'm using