Browse Source

fix: remove API key from Veo video URL response

The MAX_BASE64_SIZE check was returning the video URL with the API key
appended as a query parameter to the browser client for videos over 20MB.
Always encode to base64 instead since the buffer is already downloaded.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
handoff-20260429-1057
shrimbly 5 months ago
parent
commit
cdaf7caea8
  1. 10
      src/app/api/generate/providers/gemini.ts

10
src/app/api/generate/providers/gemini.ts

@ -320,16 +320,6 @@ export async function generateWithGeminiVideo(
const videoSizeMB = (videoBuffer.byteLength / (1024 * 1024)).toFixed(2);
console.log(`[API:${requestId}] Video downloaded: ${videoSizeMB}MB`);
// Convert to base64 data URL if small enough, otherwise return URL
const MAX_BASE64_SIZE = 20 * 1024 * 1024; // 20MB
if (videoBuffer.byteLength > MAX_BASE64_SIZE) {
console.log(`[API:${requestId}] Video too large for base64 (${videoSizeMB}MB), returning URL`);
return {
success: true,
outputs: [{ type: "video", data: "", url: videoUrl }],
};
}
const base64Video = Buffer.from(videoBuffer).toString("base64");
const dataUrl = `data:video/mp4;base64,${base64Video}`;

Loading…
Cancel
Save