fix: upload images to hosted URLs to resolve 413 errors#777
Open
selenaalpha77-sketch wants to merge 4 commits intoMerit-Systems:masterfrom
Open
fix: upload images to hosted URLs to resolve 413 errors#777selenaalpha77-sketch wants to merge 4 commits intoMerit-Systems:masterfrom
selenaalpha77-sketch wants to merge 4 commits intoMerit-Systems:masterfrom
Conversation
…rors Closes Merit-Systems#561 The previous approach passed base64-encoded images through Next.js API routes, hitting Vercel's function payload limit (FUNCTION_PAYLOAD_TOO_LARGE / HTTP 413). Changes: - Add @vercel/blob dependency for image hosting - New /api/upload-image endpoint: accepts multipart form data, stores in Vercel Blob, returns hosted URL - generate-image (openai + gemini): store generated image in Vercel Blob, return hosted URL instead of base64 - edit-image (openai): fetch images from hosted URLs server-side instead of receiving base64 - edit-image (gemini): pass hosted URLs directly (Gemini supports URL inputs natively) - edit-image (openai + gemini): store edited image in Vercel Blob, return hosted URL - image-generator.tsx: upload attachment files via /api/upload-image before sending to edit API - Remove invalid Pages Router config (export const config = { api: { bodyParser: ... } }) from App Router routes - Add export const maxDuration = 60 for longer generation timeouts on Vercel - Update .env.local and README with BLOB_READ_WRITE_TOKEN setup instructions
Contributor
|
@selenaalpha77-sketch 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.
/claim #561
Problem
Large images sent as base64 in JSON request bodies exceed Next.js's 4MB default body size limit, causing HTTP 413 errors for image generation and editing.
Solution
Images are now uploaded to Vercel Blob storage and passed as hosted URLs instead of base64 strings. This approach:
urlimage inputs)Changes
/api/upload-imageendpoint using multipart form dataFormDatainstead of base64 JSONconfig.api.bodyParserfrom App Router routesmaxDuration = 60for long-running image operations.env.localwithBLOB_READ_WRITE_TOKENinstructions