From b031ce5bbe46d0b54a52c7692f349f528c53c32c Mon Sep 17 00:00:00 2001 From: xsl Date: Mon, 7 Sep 2026 00:35:29 +0800 Subject: [PATCH] =?UTF-8?q?security:=20=E6=B8=85=E9=99=A4=E5=85=A8?= =?UTF-8?q?=E9=83=A8=E5=85=AC=E5=BC=80=E6=B5=8B=E8=AF=95=E9=A1=B5=E7=A1=AC?= =?UTF-8?q?=E7=BC=96=E7=A0=81=E7=9A=84=20worker=20=E5=86=85=E9=83=A8?= =?UTF-8?q?=E5=AF=86=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 16 个测试页移除 X-Internal-Token 硬编码(网关不校验该头,删除零影响,已线上验证) - 11/12 系列保留 token 输入框仅清空默认值,直连 worker 调试改为手输 - 接入文档 integration.html:补请求体 2MB 上限与 413 说明、HTTP 层错误提示、接口4 7 字段、补全 9/10/99 测试页入口 --- static/integration.html | 14 ++++++++++---- static/test_face_shape.html | 2 -- static/test_interface1.html | 2 +- static/test_interface10.html | 2 +- static/test_interface11.html | 2 +- static/test_interface11_debug.html | 2 +- static/test_interface12.html | 2 +- static/test_interface12_final.html | 2 -- static/test_interface12_final_v2.html | 2 -- static/test_interface2.html | 2 +- static/test_interface3.html | 2 +- static/test_interface5.html | 2 +- static/test_interface6.html | 2 +- static/test_interface7.html | 2 +- static/test_interface9.html | 2 +- static/test_interface99.html | 2 +- 16 files changed, 22 insertions(+), 22 deletions(-) diff --git a/static/integration.html b/static/integration.html index 52c346d..e83a35e 100644 --- a/static/integration.html +++ b/static/integration.html @@ -72,6 +72,7 @@ Content-Typemultipart/form-data 图片参数三选一:image_file(文件上传)/ image_url(URL)/ image_base64(base64 + 前缀) 图片格式JPG / PNG,单人正面照 + 请求体上限2MB(nginx 层限制)。超限直接返回 HTTP 413,不会进入业务逻辑。建议图片文件 ≤1MB;image_base64 传图会膨胀约 33%,编码前原图建议 ≤1.4MB。手机直拍照片通常 3~8MB,上传前务必先压缩(如最长边缩到 1500px、JPEG 质量 80)。image_url 方式图片在远端,不受此限制

统一响应结构:

@@ -190,22 +191,23 @@ const { code, data } = await res.json();

4. 用户特征分析  POST  /api/v1/face/features

-

上传照片 → 火山方舟豆包视觉模型分析 → 返回固定 6 项面部特征(脸型/眉形/面部年龄/动静类型/性别/基因风格)。

+

上传照片 → 火山方舟豆包视觉模型分析 → 返回固定 7 项面部特征(脸型/眉形/面部年龄/动静类型/性别/基因风格/轮廓类型)。

入参:image_file / image_url / image_base64 三选一。无其他参数。

data 字段

- +
字段类型说明
featuresstringJSON 字符串(不是对象!客户端需 JSON.parse())。解析后得到固定 6 个英文字段
featuresstringJSON 字符串(不是对象!客户端需 JSON.parse())。解析后得到固定 7 个英文字段
-

features 字段(固定返回 6 个):

+

features 字段(固定返回 7 个):

+
字段说明字段说明
face_shape脸型eyebrow_shape眉形
facial_age面部年龄区间gender性别
dynamic_static_type动静类型gene_style基因风格
contour_type轮廓类型(轮廓偏曲/轮廓适中/轮廓偏直)——
const res = await fetch('https://hair.xiangsilian.com/api/v1/face/features', {
@@ -309,6 +311,7 @@ console.log(features.gene_style);   // "自然型"
1009未授权缺少或错误的 X-Internal-Token(/api/* 路径鉴权)

注:1004 仍在使用(接口2/5 的 gender 校验);接口7(grow-v2)已弃用,请改用接口2。

+

⚠ HTTP 层错误不是业务 JSON:业务错误(code≠0)一律返回 HTTP 200;但请求体超 2MB 时 nginx 直接返回 413(HTML 错误页)、网关不可用时返回 502/504。客户端务必先判断 HTTP 状态码,非 200 时不要 res.json(),否则会报 Unexpected token '<'(把 HTML 当 JSON 解析)。

@@ -321,9 +324,12 @@ console.log(features.gene_style); // "自然型" 1. 四庭七眼/static/test_interface1.html上传照片 → 原图+标注叠加,底图/标注开关,指标卡片 2. C端生发/static/test_interface2.html上传+性别 → 方案一覧(原图/叠加/生发),双图对比 3. B端生发/static/test_interface3.html划线图上传 → 生发效果图 - 4. 用户特征/static/test_interface4.html上传照片 → 6项面部特征 + 原始JSON + 4. 用户特征/static/test_interface4.html上传照片 → 7项面部特征 + 原始JSON 5. 发际线PNG/static/test_interface5.html上传+性别 → 发际线方案+中心点坐标 6. 四庭七眼 v2/static/test_interface6.html同接口1,去顶庭 · 竖线发际线→下巴 · 无头部端线 + 9. 头发遮罩/static/test_interface9.html上传照片 → 头发遮罩 + 分步可视化 + 10. 外缘膨胀带/static/test_interface10.html上传照片 → 头部外缘带状遮罩 + 分步可视化 + 99. 人脸特殊点/static/test_interface99.html上传照片 → 60 关键点 + 5 发际线点坐标(测试大图请先压缩到 2MB 内,见通用约定)

完整 API 文档:/docs(Swagger UI) diff --git a/static/test_face_shape.html b/static/test_face_shape.html index 9954556..743fc51 100644 --- a/static/test_face_shape.html +++ b/static/test_face_shape.html @@ -130,7 +130,6 @@