Update server.js
Browse files
server.js
CHANGED
|
@@ -229,9 +229,12 @@ app.post('/api/proxy/rebuild/:repoId(*)', authenticateToken, async (req, res) =>
|
|
| 229 |
}
|
| 230 |
|
| 231 |
const headers = { 'Authorization': `Bearer ${space.token}`, 'Content-Type': 'application/json' };
|
| 232 |
-
|
| 233 |
-
|
| 234 |
-
|
|
|
|
|
|
|
|
|
|
| 235 |
console.log(`重建 Space ${repoId} 成功,状态码: ${response.status}`);
|
| 236 |
res.json({ success: true, message: `Space ${repoId} 重建成功` });
|
| 237 |
} catch (error) {
|
|
@@ -331,9 +334,13 @@ app.post('/api/v1/action/:token/:spaceId(*)/rebuild', async (req, res) => {
|
|
| 331 |
}
|
| 332 |
|
| 333 |
const headers = { 'Authorization': `Bearer ${token}`, 'Content-Type': 'application/json' };
|
| 334 |
-
const payload = { factory_reboot: true }; // 修改为官方 API 文档指定的字段名
|
| 335 |
console.log(`外部 API 发送重建请求,spaceId: ${spaceId}`);
|
| 336 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 337 |
console.log(`外部 API 重建 Space ${spaceId} 成功,状态码: ${response.status}`);
|
| 338 |
res.json({ success: true, message: `Space ${spaceId} 重建成功` });
|
| 339 |
} catch (error) {
|
|
|
|
| 229 |
}
|
| 230 |
|
| 231 |
const headers = { 'Authorization': `Bearer ${space.token}`, 'Content-Type': 'application/json' };
|
| 232 |
+
// 将 factory_reboot 参数作为查询参数传递,而非请求体
|
| 233 |
+
const response = await axios.post(
|
| 234 |
+
`https://huggingface.co/api/spaces/${repoId}/restart?factory=true`,
|
| 235 |
+
{},
|
| 236 |
+
{ headers }
|
| 237 |
+
);
|
| 238 |
console.log(`重建 Space ${repoId} 成功,状态码: ${response.status}`);
|
| 239 |
res.json({ success: true, message: `Space ${repoId} 重建成功` });
|
| 240 |
} catch (error) {
|
|
|
|
| 334 |
}
|
| 335 |
|
| 336 |
const headers = { 'Authorization': `Bearer ${token}`, 'Content-Type': 'application/json' };
|
|
|
|
| 337 |
console.log(`外部 API 发送重建请求,spaceId: ${spaceId}`);
|
| 338 |
+
// 将 factory_reboot 参数作为查询参数传递,而非请求体
|
| 339 |
+
const response = await axios.post(
|
| 340 |
+
`https://huggingface.co/api/spaces/${spaceId}/restart?factory=true`,
|
| 341 |
+
{},
|
| 342 |
+
{ headers }
|
| 343 |
+
);
|
| 344 |
console.log(`外部 API 重建 Space ${spaceId} 成功,状态码: ${response.status}`);
|
| 345 |
res.json({ success: true, message: `Space ${spaceId} 重建成功` });
|
| 346 |
} catch (error) {
|