Skip to content
Discussion options

You must be logged in to vote

The limit is a Vercel serverless function limitation that applies to both requests and responses. Unfortunately, using got.stream().pipe(res) doesn't bypass this limit on Vercel, even though you're streaming.

your options:

Redirect to the file directly (simplest):

Instead of proxying the file through your serverless function, redirect the client to the original URL:

const handler = async (req, res) => {
	const content_id = req.query.id;
	const file = await myDataBase.getFile(content_id);
	const {original_file_url} = file.meta;
	
	// Redirect to the original file
	res.redirect(302, original_file_url);
};

Use pre-signed URLs:

If you need access control, generate a pre-signed URL from your s…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by sindresorhus
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #2094 on July 29, 2022 06:54.