fix: prevent Request Entity Too Large (413) errors in next-image template#770
Open
tarai-dl wants to merge 1 commit intoMerit-Systems:masterfrom
Open
fix: prevent Request Entity Too Large (413) errors in next-image template#770tarai-dl wants to merge 1 commit intoMerit-Systems:masterfrom
tarai-dl wants to merge 1 commit intoMerit-Systems:masterfrom
Conversation
…late - Add client-side image resizing (max 1024px) before edit API calls to reduce base64 payload size and prevent 413 errors - Remove invalid Pages Router `config.api.bodyParser` from App Router routes - Add `maxDuration = 60` for longer image generation timeout - Use JPEG at 90% quality for resized images (smaller than PNG) Fixes Merit-Systems#561
Contributor
|
@tarai-dl is attempting to deploy a commit to the Merit Systems Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes the
HTTP 413: Request Entity Too Largeerror that occurs when editing images in thenext-imagetemplate by implementing client-side image resizing and removing invalid configuration.Closes #561
Changes
Client-side image resizing (
src/lib/image-utils.ts)resizeImageFile()function that resizes images to max 1024px dimension before uploadingUpdated image edit flow (
src/components/image-generator.tsx)resizeImageFile()instead offileToDataUrl()to reduce payload sizeRemoved invalid App Router config
export const config = { api: { bodyParser: { sizeLimit: '4mb' } } }from both route files — this is Pages Router syntax and has no effect in App Routerexport const maxDuration = 60for longer image generation timeout on VercelTesting
The fix addresses two failure modes:
maxDurationallows more time for image generation API calls