How to set Maximum Payload Size on NodeJS App

How do I increase the Maximum Payload Size that a POST request can receive in a NodeJS App running on the App Platform? If this was on Nginx, I would increase the client_max_body_size. How do I do this in an App on Digital Ocean?

More details:

I successfully deployed a SvelteKit app on the App Platform. SvelteKit provides API routes as well as frontend pages. I am sending an image from a frontend page to an API route:

Frontend code:

const imageData = canvas.toDataURL(‘image/png’); const response = await fetch(‘/api/imageTextDetection’, { method: ‘POST’, headers: { ‘Content-Type’: ‘text/plain’ }, body: imageData });

Server Code:

export const POST: RequestHandler = (async ({ request }) => { const imageData: string = await request.text(); … }

In the Browser, I am getting the following error message:

POST https://**** 413 (Payload Too Large) Error sending image to server: Error: Server responded with an error

When running the application locally, this is not giving me any error.

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

This comment has been deleted

    Hi FriendlyCeruleanAxolotl,

    Were you able to solve this problem? I currently have the EXACT same issue and am lost. I’m not sure how to increase the payload on a file uploader that posts to an api. I can’t upload anything higher than 500kb.

    Try DigitalOcean for free

    Click below to sign up and get $200 of credit to try our products over 60 days!

    Sign up

    Featured on Community

    Get our biweekly newsletter

    Sign up for Infrastructure as a Newsletter.

    Hollie's Hub for Good

    Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

    Become a contributor

    Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

    Welcome to the developer cloud

    DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

    Learn more
    DigitalOcean Cloud Control Panel