Update server.js
Browse files
server.js
CHANGED
|
@@ -154,10 +154,19 @@ app.get('/api/comfyui/history/:promptId', async (req, res) => {
|
|
| 154 |
const { comfyuiUrl } = req.query;
|
| 155 |
const { promptId } = req.params;
|
| 156 |
|
|
|
|
| 157 |
if (!comfyuiUrl) {
|
|
|
|
| 158 |
return res.status(400).json({ error: '缺少ComfyUI URL' });
|
| 159 |
}
|
| 160 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 161 |
const response = await fetch(`${comfyuiUrl}/history/${promptId}`, {
|
| 162 |
headers: {
|
| 163 |
'Accept': 'application/json',
|
|
@@ -165,6 +174,8 @@ app.get('/api/comfyui/history/:promptId', async (req, res) => {
|
|
| 165 |
});
|
| 166 |
|
| 167 |
if (!response.ok) {
|
|
|
|
|
|
|
| 168 |
throw new Error(`获取历史失败: ${response.status}`);
|
| 169 |
}
|
| 170 |
|
|
@@ -173,7 +184,10 @@ app.get('/api/comfyui/history/:promptId', async (req, res) => {
|
|
| 173 |
|
| 174 |
} catch (error) {
|
| 175 |
console.error('History error:', error);
|
| 176 |
-
res.status(500).json({
|
|
|
|
|
|
|
|
|
|
| 177 |
}
|
| 178 |
});
|
| 179 |
|
|
|
|
| 154 |
const { comfyuiUrl } = req.query;
|
| 155 |
const { promptId } = req.params;
|
| 156 |
|
| 157 |
+
// 验证参数
|
| 158 |
if (!comfyuiUrl) {
|
| 159 |
+
console.error('缺少ComfyUI URL参数');
|
| 160 |
return res.status(400).json({ error: '缺少ComfyUI URL' });
|
| 161 |
}
|
| 162 |
|
| 163 |
+
if (!promptId) {
|
| 164 |
+
console.error('缺少promptId参数');
|
| 165 |
+
return res.status(400).json({ error: '缺少promptId' });
|
| 166 |
+
}
|
| 167 |
+
|
| 168 |
+
console.log(`获取历史: ${comfyuiUrl}/history/${promptId}`);
|
| 169 |
+
|
| 170 |
const response = await fetch(`${comfyuiUrl}/history/${promptId}`, {
|
| 171 |
headers: {
|
| 172 |
'Accept': 'application/json',
|
|
|
|
| 174 |
});
|
| 175 |
|
| 176 |
if (!response.ok) {
|
| 177 |
+
const errorText = await response.text();
|
| 178 |
+
console.error(`ComfyUI历史请求失败: ${response.status}`, errorText);
|
| 179 |
throw new Error(`获取历史失败: ${response.status}`);
|
| 180 |
}
|
| 181 |
|
|
|
|
| 184 |
|
| 185 |
} catch (error) {
|
| 186 |
console.error('History error:', error);
|
| 187 |
+
res.status(500).json({
|
| 188 |
+
error: error.message,
|
| 189 |
+
details: '无法从ComfyUI获取生成历史,请检查ComfyUI是否正常运行'
|
| 190 |
+
});
|
| 191 |
}
|
| 192 |
});
|
| 193 |
|