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. 防攻击策略