Update server.js
Browse files
server.js
CHANGED
|
@@ -131,7 +131,12 @@ app.get('/api/proxy/spaces', async (req, res) => {
|
|
| 131 |
try {
|
| 132 |
if (!spaceCache.isExpired()) {
|
| 133 |
console.log('从缓存获取 Spaces 数据');
|
| 134 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 135 |
}
|
| 136 |
|
| 137 |
const allSpaces = [];
|
|
@@ -160,7 +165,7 @@ app.get('/api/proxy/spaces', async (req, res) => {
|
|
| 160 |
name: spaceInfo.cardData?.title || spaceInfo.id.split('/')[1],
|
| 161 |
owner: spaceInfo.author,
|
| 162 |
username: username,
|
| 163 |
-
|
| 164 |
url: `https://${spaceInfo.author}-${spaceInfo.id.split('/')[1]}.hf.space`,
|
| 165 |
status: spaceRuntime.stage || 'unknown',
|
| 166 |
last_modified: spaceInfo.lastModified || 'unknown',
|
|
|
|
| 131 |
try {
|
| 132 |
if (!spaceCache.isExpired()) {
|
| 133 |
console.log('从缓存获取 Spaces 数据');
|
| 134 |
+
// 从缓存返回的数据也需要过滤掉 token 字段
|
| 135 |
+
const cachedSpaces = spaceCache.getAll().map(space => {
|
| 136 |
+
const { token, ...safeSpace } = space; // 移除 token 字段
|
| 137 |
+
return safeSpace;
|
| 138 |
+
});
|
| 139 |
+
return res.json(cachedSpaces);
|
| 140 |
}
|
| 141 |
|
| 142 |
const allSpaces = [];
|
|
|
|
| 165 |
name: spaceInfo.cardData?.title || spaceInfo.id.split('/')[1],
|
| 166 |
owner: spaceInfo.author,
|
| 167 |
username: username,
|
| 168 |
+
// 不再直接包含 token 字段,而是仅在后端使用
|
| 169 |
url: `https://${spaceInfo.author}-${spaceInfo.id.split('/')[1]}.hf.space`,
|
| 170 |
status: spaceRuntime.stage || 'unknown',
|
| 171 |
last_modified: spaceInfo.lastModified || 'unknown',
|