diff --git a/next.config.ts b/next.config.ts index e2916b01..a3c62094 100644 --- a/next.config.ts +++ b/next.config.ts @@ -4,9 +4,12 @@ const nextConfig: NextConfig = { reactStrictMode: true, experimental: { serverActions: { - bodySizeLimit: "50mb", + bodySizeLimit: "100mb", // Increased for large media files }, }, + // Note: For route handlers (.../route.ts files), body size is controlled by + // the underlying server. For large payloads, consider using streaming or + // increase Node.js max HTTP header size if needed. turbopack: { root: __dirname, }, diff --git a/src/app/api/save-generation/route.ts b/src/app/api/save-generation/route.ts index d4f22c18..f5bfaabc 100644 --- a/src/app/api/save-generation/route.ts +++ b/src/app/api/save-generation/route.ts @@ -4,6 +4,8 @@ import * as path from "path"; import * as crypto from "crypto"; import { logger } from "@/utils/logger"; +export const maxDuration = 300; // 5 minute timeout for large media operations + // Helper to get file extension from MIME type function getExtensionFromMime(mimeType: string): string { const mimeToExt: Record = { diff --git a/src/utils/mediaStorage.ts b/src/utils/mediaStorage.ts index 16889120..17a3614d 100644 --- a/src/utils/mediaStorage.ts +++ b/src/utils/mediaStorage.ts @@ -613,10 +613,9 @@ async function saveVideoAndGetRef( method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ - workflowPath, - id: videoId, - data: videoData, - type: "video", + directoryPath: workflowPath, + imageId: videoId, + video: videoData, }), }, 60000 // 60s timeout for larger video files @@ -680,10 +679,9 @@ async function saveAudioAndGetRef( method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ - workflowPath, - id: audioId, - data: audioData, - type: "audio", + directoryPath: workflowPath, + imageId: audioId, + audio: audioData, }), }, 60000 // 60s timeout for larger audio files @@ -1038,12 +1036,14 @@ async function loadMediaById( response = await fetch(`/api/workflow-images?${params.toString()}`); } else { // Use load-generation API for videos and audio - const params = new URLSearchParams({ - workflowPath, - id: mediaId, + response = await fetch("/api/load-generation", { + method: "POST", + headers: { "Content-Type": "application/json" }, + body: JSON.stringify({ + directoryPath: workflowPath, + imageId: mediaId, + }), }); - - response = await fetch(`/api/load-generation?${params.toString()}`); } const result = await response.json();