docs(cors): X-API-Version 明确为 advisory 惯例头(E1) — 消除版本协商假象
CI / Backend (build / vet / test / cross-compile) (push) Has been cancelled
CI / Frontend (tsc + vite build) (push) Has been cancelled

- middleware: CORS Allow-Headers 加 X-API-Version(跨域客户端不再预检失败)
- api-reference §0.2 + api-client §4.1: 声明服务端不校验、不据此协商版本
- 后端/前端零行为改动(前端仍在发,现CORS放行)
This commit is contained in:
AskaEth committed 2026-09-08 21:24:36 +08:00
1 parent 99f222761e
commit 3fc10fb86f
3 files changed
+4 -4

No files matched your search

+1 -1
View File
@@ -183,7 +183,7 @@
### 4.1 一次性接入流程(三步走)
1. **拿令牌**:`POST /api/v1/auth/login` `{username,password}` → `{data:{token,expiresAt,role}}`(JWT,默认 24h,`role` ∈ `owner|admin|viewer`)。
2. **声明版本**:后续每个请求头带上 `X-API-Version: 1` + `Authorization: Bearer <token>`;WS 握手用 `ws://<host>:<port>/ws/chat?token=<token>`(或 `Authorization: Bearer`)。**viewer 只能读会话/人格元数据;读写会话消息、管理写操作需 `owner`/`admin`。**
2. **声明版本(可选/advisory)**:可带 `X-API-Version: 1` + `Authorization: Bearer <token>`;WS 握手用 `ws://<host>:<port>/ws/chat?token=<token>`(或 `Authorization: Bearer`)。**`X-API-Version` 是**advisory**惯例头——服务端当前不校验、不据此协商版本,带不带行为不变**;`viewer` 只能读会话/人格元数据;读写会话消息、管理写操作需 `owner`/`admin`。
3. **带端标识**(可选但推荐):每条消息/请求可带 `deviceId`(见 §4.3),让她知道你从哪个端来。
### 4.2 会话与消息用法(聊天)