Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get around Nextjs 4.5 mb payload size limit #2094

Closed
aquaductape opened this issue Jul 29, 2022 · 0 comments
Closed

How to get around Nextjs 4.5 mb payload size limit #2094

aquaductape opened this issue Jul 29, 2022 · 0 comments

Comments

@aquaductape
Copy link

Vercel has the maximum payload size for the request body or the response body of a Serverless Function is 4.5 MB.

So anytime this function is serving a file larger than 4.5 MB, I get 413: FUNCTION_PAYLOAD_TOO_LARGE error.

Is there any way to work around this using got

import got from 'got'

const handler = async (req, res) => {
  if (req.method.toUpperCase() !== 'GET') return res.status(500).json({});

  const content_id = req.query.id;
  const file = await myDataBase.getFile(content_id)

  const { url, original_filename, original_file_url } = file.meta;

  try {
    got.stream(original_file_url).pipe(res);
  } catch (error) {
    return res.status(500).send(null);
  }

};

export default handler;
Repository owner locked and limited conversation to collaborators Jul 29, 2022
@sindresorhus sindresorhus converted this issue into discussion #2095 Jul 29, 2022

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant