Can someone help me out

I’m experiencing HTTP 500 (Internal Server Error) when trying to pass data back to my frontend to display. The n8n interface loads and shows my workflow canvas which looks fine, but I’m getting server errors that prevent proper execution on the frontend console. The frontend is meant to send a prompt through webhook, n8n is receiving the prompt fine and processing it correctly and sending it back through respond to the webhook node but the http 500 error appears in my browser console and my frontend


<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Prompt Submission App</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            min-height: 100vh;
            display: flex;
            justify-content: center;
            align-items: center;
        }

        .container {
            background: white;
            border-radius: 20px;
            box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
            padding: 40px;
            width: 100%;
            max-width: 500px;
            text-align: center;
        }

        .page {
            display: none;
        }

        .page.active {
            display: block;
        }

        h1 {
            color: #333;
            margin-bottom: 30px;
            font-size: 2.5em;
            font-weight: 300;
        }

        .form-group {
            margin-bottom: 30px;
            text-align: left;
        }

        label {
            display: block;
            margin-bottom: 10px;
            color: #555;
            font-weight: 500;
        }

        input[type="text"] {
            width: 100%;
            padding: 15px;
            border: 2px solid #e0e0e0;
            border-radius: 10px;
            font-size: 16px;
            transition: border-color 0.3s ease;
        }

        input[type="text"]:focus {
            outline: none;
            border-color: #667eea;
        }

        .submit-btn {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            padding: 15px 30px;
            border: none;
            border-radius: 10px;
            font-size: 18px;
            cursor: pointer;
            transition: transform 0.3s ease, box-shadow 0.3s ease;
            width: 100%;
        }

        .submit-btn:hover {
            transform: translateY(-2px);
            box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
        }

        .submit-btn:disabled {
            opacity: 0.6;
            cursor: not-allowed;
            transform: none;
        }

        .back-btn {
            background: #6c757d;
            color: white;
            padding: 10px 20px;
            border: none;
            border-radius: 8px;
            font-size: 14px;
            cursor: pointer;
            margin-bottom: 20px;
            transition: background-color 0.3s ease;
        }

        .back-btn:hover {
            background: #5a6268;
        }

        .card {
            background: #f8f9fa;
            border-radius: 15px;
            padding: 30px;
            margin-top: 20px;
            box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
        }

        .card img {
            max-width: 100%;
            height: auto;
            border-radius: 10px;
            margin-bottom: 20px;
            box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
        }

        .revised-prompt {
            background: white;
            padding: 20px;
            border-radius: 10px;
            border-left: 4px solid #667eea;
            text-align: left;
            margin-top: 20px;
        }

        .revised-prompt h3 {
            color: #333;
            margin-bottom: 10px;
            font-size: 1.2em;
        }

        .revised-prompt p {
            color: #666;
            line-height: 1.6;
        }

        .loading {
            display: none;
            text-align: center;
            padding: 20px;
        }

        .loading.active {
            display: block;
        }

        .spinner {
            border: 4px solid #f3f3f3;
            border-top: 4px solid #667eea;
            border-radius: 50%;
            width: 40px;
            height: 40px;
            animation: spin 1s linear infinite;
            margin: 0 auto 20px;
        }

        @keyframes spin {
            0% { transform: rotate(0deg); }
            100% { transform: rotate(360deg); }
        }

        .error {
            color: #dc3545;
            background: #f8d7da;
            padding: 15px;
            border-radius: 10px;
            margin-top: 20px;
            border: 1px solid #f5c6cb;
        }
    </style>
</head>
<body>
    <div class="container">
        <!-- Page 1: Form Submission -->
        <div id="page1" class="page active">
            <h1>Submit Your Prompt</h1>
            <form id="promptForm">
                <div class="form-group">
                    <label for="prompt">Enter your prompt:</label>
                    <input type="text" id="prompt" name="prompt" required placeholder="Type your prompt here...">
                </div>
                <button type="submit" class="submit-btn" id="submitBtn">Submit</button>
            </form>
            <div id="loading" class="loading">
                <div class="spinner"></div>
                <p>Processing your request...</p>
            </div>
            <div id="error" class="error" style="display: none;"></div>
        </div>

        <!-- Page 2: Result Display -->
        <div id="page2" class="page">
            <button class="back-btn" onclick="goBack()">← Back to Form</button>
            <h1>Generated Result</h1>
            <div class="card" id="resultCard">
                <img id="resultImage" src="" alt="Generated Image">
                <div class="revised-prompt">
                    <h3>Revised Prompt</h3>
                    <p id="revisedPromptText"></p>
                </div>
            </div>
        </div>
    </div>

    <script>
        const form = document.getElementById('promptForm');
        const submitBtn = document.getElementById('submitBtn');
        const loading = document.getElementById('loading');
        const errorDiv = document.getElementById('error');
        const page1 = document.getElementById('page1');
        const page2 = document.getElementById('page2');
        const resultImage = document.getElementById('resultImage');
        const revisedPromptText = document.getElementById('revisedPromptText');

        // Replace with your actual webhook URL
        const WEBHOOK_URL = 'my webhook link (hidden)';

        form.addEventListener('submit', async (e) => {
            e.preventDefault();
            
            const promptValue = document.getElementById('prompt').value.trim();
            
            if (!promptValue) {
                showError('Please enter a prompt');
                return;
            }

            try {
                // Show loading state
                submitBtn.disabled = true;
                loading.classList.add('active');
                errorDiv.style.display = 'none';

                const response = await fetch(WEBHOOK_URL, {
                    method: 'POST',
                    headers: {
                        'Content-Type': 'application/json',
                    },
                    body: JSON.stringify({
                        prompt: promptValue
                    })
                });

                if (!response.ok) {
                    throw new Error(`HTTP error! status: ${response.status}`);
                }

                const data = await response.json();
                
                // Validate response structure
                if (!data.image_url || !data.revised_prompt) {
                    throw new Error('Invalid response format from server');
                }

                // Display results
                displayResults(data);

            } catch (error) {
                console.error('Error:', error);
                showError('Failed to process your request. Please try again.');
            } finally {
                // Hide loading state
                submitBtn.disabled = false;
                loading.classList.remove('active');
            }
        });

        function displayResults(data) {
            resultImage.src = data.image_url;
            revisedPromptText.textContent = data.revised_prompt;
            
            // Switch to page 2
            page1.classList.remove('active');
            page2.classList.add('active');
        }

        function showError(message) {
            errorDiv.textContent = message;
            errorDiv.style.display = 'block';
        }

        function goBack() {
            page2.classList.remove('active');
            page1.classList.add('active');
            
            // Reset form
            document.getElementById('prompt').value = '';
            errorDiv.style.display = 'none';
        }

        // Handle image loading errors
        resultImage.addEventListener('error', () => {
            resultImage.alt = 'Failed to load image';
            resultImage.style.display = 'none';
        });
    </script>
</body>
</html>

can you show us the full workflow too? you can copy the workflow here by selecting the nodes, and paste here with triple (`) at before and after code, like this ```code```
thanks

  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "textprompt",
        "responseMode": "responseNode",
        "options": {}
      },
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        340,
        340
      ],
      "id": "5536158e-7f6b-4129-b78e-f88821cbd5f3",
      "name": "Webhook",
      "webhookId": "a0ed5fef-4418-4e6b-bb46-ae5be7025920"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.openai.com/v1/images/generations",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "model",
              "value": "gpt-image-1"
            },
            {
              "name": "prompt",
              "value": "={{ $json.output }}"
            },
            {
              "name": "size",
              "value": "1024x1024"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        900,
        340
      ],
      "id": "59b16e29-4da6-46e7-9157-f0ae52ca0cb5",
      "name": "HTTP Request",
      "credentials": {
        "httpHeaderAuth": {
          "id": "d0u6qjvCugiPj9fi",
          "name": "chat image"
        }
      }
    },
    {
      "parameters": {
        "operation": "toBinary",
        "sourceProperty": "data[0].b64_json",
        "options": {}
      },
      "type": "n8n-nodes-base.convertToFile",
      "typeVersion": 1.1,
      "position": [
        1160,
        400
      ],
      "id": "77f77d76-bb15-4765-abde-f1573dbaa154",
      "name": "Convert to File"
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "value": "gpt-4.1",
          "mode": "list",
          "cachedResultName": "gpt-4.1"
        },
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.2,
      "position": [
        580,
        540
      ],
      "id": "600fba8d-2ac7-4954-81a3-fd9de4d10af0",
      "name": "OpenAI Chat Model",
      "credentials": {
        "openAiApi": {
          "id": "7nO0m1QmAV9ZGCvi",
          "name": "OpenAi account 2"
        }
      }
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "={{ $json.body.prompt }}",
        "options": {
          "systemMessage": "Role:\nYou are an AI image prompt generator. Your role is to interpret technical data and convert it into high-quality, visually descriptive prompts for image generation models."
        }
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 1.8,
      "position": [
        580,
        340
      ],
      "id": "189cba05-a0ab-47eb-b1a2-decbe3b65685",
      "name": "Image Agent"
    },
    {
      "parameters": {
        "respondWith": "allIncomingItems",
        "options": {}
      },
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.4,
      "position": [
        1780,
        460
      ],
      "id": "f6b8b509-eeab-4026-acee-89d80c8518c4",
      "name": "Respond to Webhook"
    },
    {
      "parameters": {
        "authentication": "serviceAccount",
        "name": "={{ $now }}",
        "driveId": {
          "__rl": true,
          "value": "17M230v0v-LQO1GOGK-coxze6My0oZxHv",
          "mode": "id"
        },
        "folderId": {
          "__rl": true,
          "mode": "list",
          "value": "root",
          "cachedResultName": "/ (Root folder)"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleDrive",
      "typeVersion": 3,
      "position": [
        1420,
        440
      ],
      "id": "7caeac96-c0ad-4f61-be02-54b09f52ac0d",
      "name": "Upload file",
      "credentials": {
        "googleApi": {
          "id": "GcXxQEn6yc6RRgVf",
          "name": "Google Service Account account"
        }
      }
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "a5e4bae9-efa5-426d-b9d1-423cb464b711",
              "name": "image_url",
              "value": "={{ $json.webViewLink }}",
              "type": "string"
            },
            {
              "id": "c67f888d-45ea-4008-a786-194452925928",
              "name": "revised_prompt",
              "value": "={{ $('Image Agent').item.json.output }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        1620,
        300
      ],
      "id": "d5693a05-e076-4c7b-8ed3-b235dc18892f",
      "name": "Edit Fields"
    }
  ],
  "connections": {
    "Webhook": {
      "main": [
        [
          {
            "node": "Image Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request": {
      "main": [
        [
          {
            "node": "Convert to File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Convert to File": {
      "main": [
        [
          {
            "node": "Upload file",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Image Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Image Agent": {
      "main": [
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Respond to Webhook": {
      "main": [
        []
      ]
    },
    "Upload file": {
      "main": [
        [
          {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields": {
      "main": [
        [
          {
            "node": "Respond to Webhook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "pinData": {
    "Webhook": [
      {
        "headers": {
          "host": "gabrielpt.app.n8n.cloud",
          "user-agent": "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Mobile Safari/537.36",
          "content-length": "30",
          "accept": "*/*",
          "accept-encoding": "gzip, br",
          "accept-language": "en-US,en;q=0.9",
          "cdn-loop": "cloudflare; loops=1; subreqs=1",
          "cf-connecting-ip": "100.40.113.191",
          "cf-ew-via": "15",
          "cf-ipcountry": "US",
          "cf-ray": "95cc62a5131def9d-EWR",
          "cf-visitor": "{\"scheme\":\"https\"}",
          "cf-worker": "n8n.cloud",
          "content-type": "application/json",
          "origin": "http://127.0.0.1:8080",
          "priority": "u=1, i",
          "referer": "http://127.0.0.1:8080/",
          "sec-ch-ua": "\"Not)A;Brand\";v=\"8\", \"Chromium\";v=\"138\", \"Google Chrome\";v=\"138\"",
          "sec-ch-ua-mobile": "?1",
          "sec-ch-ua-platform": "\"Android\"",
          "sec-fetch-dest": "empty",
          "sec-fetch-mode": "cors",
          "sec-fetch-site": "cross-site",
          "x-forwarded-for": "100.40.113.191, 172.70.115.215",
          "x-forwarded-host": "gabrielpt.app.n8n.cloud",
          "x-forwarded-port": "443",
          "x-forwarded-proto": "https",
          "x-forwarded-server": "traefik-prod-users-gwc-28-7b57cfbbf9-929lf",
          "x-is-trusted": "yes",
          "x-real-ip": "100.40.113.191"
        },
        "params": {},
        "query": {},
        "body": {
          "prompt": "i want a cute rat"
        },
        "webhookUrl": "https://gabrielpt.app.n8n.cloud/webhook/textprompt",
        "executionMode": "production"
      }
    ]
  },
  "meta": {
    "instanceId": "a27d4a5c667e24cf7ec33f796e6385a2bc2710ba851112f11a82591065aef9a1"
  }
}```

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.