diff --git a/app/api/missions/route.ts b/app/api/missions/route.ts index 17980a51..013c1536 100644 --- a/app/api/missions/route.ts +++ b/app/api/missions/route.ts @@ -246,6 +246,15 @@ export async function POST(request: Request) { const firstResult = workflowResult.results[0]; console.log('First result from workflow:', JSON.stringify(firstResult, null, 2)); + // Check if the result is HTML (error case) + if (typeof firstResult === 'string' && firstResult.includes('')) { + console.error('Received HTML response instead of JSON:', firstResult); + return NextResponse.json({ + error: 'Invalid response from workflow', + details: 'Received HTML instead of JSON data' + }, { status: 500 }); + } + if (firstResult && firstResult.json && firstResult.json.logoPath) { logoPath = firstResult.json.logoPath; console.log('Extracted logo path:', logoPath);