Spaces:
Sleeping
Sleeping
| // API Proxy for ComfyUI | |
| export default async function handler(req, res) { | |
| if (req.method !== 'POST') { | |
| return res.status(405).json({ message: 'Method not allowed' }); | |
| } | |
| const { prompt } = req.body; | |
| // NOTE: Replace with your actual ComfyUI endpoint | |
| const COMFYUI_URL = process.env.COMFYUI_URL || 'http://localhost:8188'; | |
| try { | |
| // This is a simplified mock logic for the proxy structure. | |
| // In a real scenario, you would send a workflow object to ComfyUI. | |
| // Example: | |
| // const response = await fetch(`${COMFYUI_URL}/prompt`, { | |
| // method: 'POST', | |
| // headers: { 'Content-Type': 'application/json' }, | |
| // body: JSON.stringify({ prompt: prompt }), | |
| // }); | |
| // Simulating a delay | |
| await new Promise(resolve => setTimeout(resolve, 1500)); | |
| // Mock response | |
| return res.status(200).json({ | |
| url: 'https://picsum.photos/seed/' + encodeURIComponent(prompt) + '/800/450' | |
| }); | |
| } catch (error) { | |
| console.error('ComfyUI Error:', error); | |
| return res.status(500).json({ message: 'Internal Server Error' }); | |
| } | |
| } |