W n8n
This commit is contained in:
parent
3cb22a643f
commit
66140b9220
@ -209,12 +209,18 @@ export async function POST(request: Request) {
|
||||
};
|
||||
|
||||
try {
|
||||
console.log('Sending data to n8n workflow:', {
|
||||
...n8nData,
|
||||
password: undefined // Don't log sensitive data
|
||||
});
|
||||
|
||||
const workflowResult = await n8nService.triggerMissionCreation(n8nData);
|
||||
|
||||
if (!workflowResult.success) {
|
||||
console.error('n8n workflow failed:', workflowResult.error);
|
||||
return NextResponse.json({
|
||||
error: 'Failed to create mission resources',
|
||||
details: workflowResult.error,
|
||||
details: workflowResult.error || 'The mission creation process failed',
|
||||
code: 'WORKFLOW_ERROR'
|
||||
}, { status: 500 });
|
||||
}
|
||||
@ -222,6 +228,21 @@ export async function POST(request: Request) {
|
||||
return NextResponse.json(workflowResult);
|
||||
} catch (error) {
|
||||
console.error('Error triggering n8n workflow:', error);
|
||||
|
||||
// Check if it's an n8n workflow error
|
||||
if (error instanceof Error && error.message.includes('HTTP error! status: 500')) {
|
||||
return NextResponse.json(
|
||||
{
|
||||
error: 'Mission creation workflow failed',
|
||||
details: 'The mission creation process encountered an error. Please try again later.',
|
||||
code: 'WORKFLOW_ERROR',
|
||||
originalError: error.message
|
||||
},
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
|
||||
// Handle other types of errors
|
||||
return NextResponse.json(
|
||||
{
|
||||
error: 'Failed to create mission resources',
|
||||
|
||||
Loading…
Reference in New Issue
Block a user