00Boobs00's picture
Upload pages/api/comfy.js with huggingface_hub
daa811e verified
raw
history blame contribute delete
760 Bytes
// 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;
const COMFYUI_URL = process.env.COMFYUI_URL || 'http://localhost:8188';
try {
// Simulate processing time
await new Promise(resolve => setTimeout(resolve, 2000));
// Return a deterministic image based on prompt for consistency
const seed = encodeURIComponent(prompt.replace(/\s/g, ''));
return res.status(200).json({
url: `https://picsum.photos/seed/${seed}/800/450`
});
} catch (error) {
console.error('ComfyUI Error:', error);
return res.status(500).json({ message: 'Internal Server Error' });
}
}