From f87b1b04608a686a35c846ef512ca7237ec24a71 Mon Sep 17 00:00:00 2001
From: hrz <1710360675@qq.com>
Date: Thu, 22 Oct 2026 01:26:14 +0000
Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E6=8E=89=E6=B5=8B=E8=AF=95=E5=AE=A2?=
=?UTF-8?q?=E6=88=B7=E7=AB=AF=E8=B7=B3=E8=BF=87=E8=AE=A4=E8=AF=81=E7=9A=84?=
=?UTF-8?q?=E5=90=8E=E9=97=A8?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
视觉分析接口里写死了 client_id 等于 web_test_client 就放行,等于不用
凭证就能调收费的图像识别,还顺带能拿任意设备号去读私有配置。把这行
删掉。数字人页面原来默认填的就是这个值,也一起清掉,取不到就提示
用户填,避免静默用一个服务端已经不认的值。
---
main/digital-human/index.html | 2 +-
main/digital-human/js/app.js | 5 ++++-
main/xiaozhi-server/core/api/vision_handler.py | 11 ++---------
3 files changed, 7 insertions(+), 11 deletions(-)
diff --git a/main/digital-human/index.html b/main/digital-human/index.html
index cfb72637f..d633dc7f4 100644
--- a/main/digital-human/index.html
+++ b/main/digital-human/index.html
@@ -155,7 +155,7 @@
-
+
diff --git a/main/digital-human/js/app.js b/main/digital-human/js/app.js
index 09ab35063..62f758da0 100644
--- a/main/digital-human/js/app.js
+++ b/main/digital-human/js/app.js
@@ -304,7 +304,10 @@ class App {
log(`正在发送图片到视觉分析接口: ${url}`, 'info');
const deviceId = document.getElementById('deviceMac')?.value || '';
- const clientId = document.getElementById('clientId')?.value || 'web_test_client';
+ const clientId = document.getElementById('clientId')?.value || '';
+ if (!deviceId || !clientId) {
+ throw new Error('视觉分析失败:请填写设备MAC与客户端ID,两者需与设备上报的一致');
+ }
const formData = new FormData();
formData.append('question', question);
diff --git a/main/xiaozhi-server/core/api/vision_handler.py b/main/xiaozhi-server/core/api/vision_handler.py
index c3e683cfe..587c08cf7 100644
--- a/main/xiaozhi-server/core/api/vision_handler.py
+++ b/main/xiaozhi-server/core/api/vision_handler.py
@@ -29,14 +29,7 @@ class VisionHandler(BaseHandler):
def _verify_auth_token(self, request) -> Tuple[bool, Optional[str]]:
"""验证认证token"""
- # 测试模式:允许特定测试令牌或跳过验证
auth_header = request.headers.get("Authorization", "")
- client_id = request.headers.get("Client-Id", "")
-
- # 允许测试客户端跳过认证
- if client_id == "web_test_client":
- device_id = request.headers.get("Device-Id", "test_device")
- return True, device_id
if not auth_header.startswith("Bearer "):
return False, None
@@ -155,7 +148,7 @@ class VisionHandler(BaseHandler):
)
finally:
if response:
- self._add_cors_headers(response)
+ self._add_cors_headers(response, request)
return response
async def handle_get(self, request):
@@ -178,5 +171,5 @@ class VisionHandler(BaseHandler):
content_type="application/json",
)
finally:
- self._add_cors_headers(response)
+ self._add_cors_headers(response, request)
return response