fix: 修复批量刷新 SSE 连接认证失败问题

- batch-sse.js: 传递 api_key 前去除 Bearer 前缀
- 根因: admin-auth.js 返回的 apiKey 包含 Bearer 前缀,但后端期望原始 key
This commit is contained in:
piexian committed 2026-02-04 06:07:55 +08:00
1 parent d605e0338f
commit b37b123ea7
1 file changed
+3 -1
+3 -1
View File
@@ -1,7 +1,9 @@
(function (global) {
function openBatchStream(taskId, apiKey, handlers = {}) {
if (!taskId) return null;
const url = `/api/v1/admin/batch/${taskId}/stream?api_key=${encodeURIComponent(apiKey || '')}`;
// Strip "Bearer " prefix if present - query param expects raw key
const rawKey = apiKey && apiKey.startsWith('Bearer ') ? apiKey.slice(7) : apiKey;
const url = `/api/v1/admin/batch/${taskId}/stream?api_key=${encodeURIComponent(rawKey || '')}`;
const es = new EventSource(url);
es.onmessage = (e) => {