From 910e71b6f0d4596f407fbe2f677b592c51bc41bc Mon Sep 17 00:00:00 2001 From: hhs <386998068@qq.com> Date: Sun, 21 Jun 2026 13:10:48 +0800 Subject: [PATCH] =?UTF-8?q?docs:=20=E8=A7=84=E8=8C=83=E6=96=87=E6=A1=A3?= =?UTF-8?q?=E5=AF=B9=E8=B7=A8=E5=9F=9F=E5=A4=84=E7=90=86=E7=9A=84=E4=BB=8B?= =?UTF-8?q?=E7=BB=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CLAUDE.md | 1 + docs/12-鉴权体系设计.md | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CLAUDE.md b/CLAUDE.md index 2c4a8b8..060d6c5 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -288,6 +288,7 @@ CAMTALK_AI_LLM_API_KEY=sk-xxx CAMTALK_AI_STT_API_KEY=xxx go run ./cmd/server - **Go**:遵循标准 Go 规范。所有 AI 调用使用 `context.Context` 做取消/超时。并发 map 访问使用 `sync.RWMutex`。结构体标签用 `json:"snake_case"`。编译期接口检查 `var _ Interface = (*Impl)(nil)`。 - **TypeScript**:严格模式(`strict: true`)。所有数据模型用接口定义。WebSocket 消息类型用可辨识联合类型(`type` 字段)。`verbatimModuleSyntax: true`(强制 `import type`)。未使用变量以 `_` 前缀忽略。 +- **CORS 处理**:禁止在后端代码和配置文件(`config/*.yaml`)中进行任何 CORS 配置。跨域由代理层统一处理:开发环境通过 `frontend/vite.config.ts` 中的 proxy 配置(`/ws`、`/api` 代理到 `localhost:8080`),生产环境通过 Nginx 反向代理(`frontend/nginx.conf`)。 - **提交信息**:Conventional Commits 格式,描述用中文。示例:`feat: 添加 WebSocket 连接管理`、`fix: 修复心跳超时判断`、`docs: 更新接口文档` - **禁止自动 push**:除非用户明确要求。 - **文档优先**:实现功能前先读取 `docs/` 下的相关设计文档。实现与文档不一致时,优先更新 `docs/` 下的接口文档。 diff --git a/docs/12-鉴权体系设计.md b/docs/12-鉴权体系设计.md index 3c3fb74..e59d231 100644 --- a/docs/12-鉴权体系设计.md +++ b/docs/12-鉴权体系设计.md @@ -426,7 +426,7 @@ ws.onerror = (error) => { ### 3. 传输安全 - **HTTPS 强制**:生产环境必须使用 HTTPS -- **CORS 限制**:配置 `AllowedOrigins` 限制允许的域名 +- **同源反代**:通过 Nginx 反向代理(生产)或 Vite proxy(开发)统一前后端到同一域名,浏览器层面无跨域问题 - **HttpOnly Cookie**:refresh_token 存储在 httpOnly Cookie 中,防止 XSS 攻击 ### 4. 防攻击策略 -- 2.49.1