TanWenyan
|
3254cec5ca
|
修复Dify对话记录加载问题:移除user参数,由后端自动管理
问题描述:
- 用户登录后无法加载历史对话记录
- 根本原因:前端传递的user值与实际用户不一致,导致Dify无法找到对应的对话
解决方案:
- 后端已实现user字段自动填充功能(v1.2.7-post2)
- 前端采用方案A:完全移除user参数传递
- 让后端从JWT中自动提取username并管理user字段
修改内容:
1. dify-client.server.ts
- 移除所有方法的user参数
- GET请求移除user查询参数
- POST/DELETE请求移除user字段
- 移除generateUserId工具函数
2. 所有API路由
- 移除getSessionInfo中的user解构
- 移除difyClient方法调用中的user参数传递
- 日志中移除user信息输出
影响接口:
- GET /dify/conversations - 会话列表
- GET /dify/messages - 消息历史
- POST /dify/chat-messages - 发送消息
- POST /dify/conversations/{id}/name - 重命名会话
- DELETE /dify/conversations/{id} - 删除会话
- POST /dify/messages/{id}/feedbacks - 消息反馈
参考文档:docs/dify-frontend-user-field-guide.md
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
|
2025-10-30 10:37:45 +08:00 |
|
TanWenyan
|
c4c08cb59b
|
重构Dify客户端:改为通过FastAPI代理并使用JWT认证
主要变更:
- 修改 dify-client.server.ts 使用 JWT 认证通过 FastAPI 后端代理访问 Dify API
- 所有 Dify API 路由(chat-messages, parameters, conversations, messages)添加 JWT 获取和传递逻辑
- API_URL 从直连 Dify 改为 FastAPI 后端的 /dify 路由
- 增强 JWT 认证失败的错误处理(返回401状态码)
- 添加详细的日志输出,便于调试
安全提升:
- DIFY_API_KEY 从前端移至后端,不再暴露在客户端代码
- 使用统一的 JWT 认证体系,提高系统安全性
文档:
- 新增 dify-proxy-backend-integration.md - 后端对接文档(包含完整 FastAPI 实现示例)
- 新增 dify-frontend-modification-summary.md - 前端修改总结
- 新增 CLAUDE.md - 项目架构说明文档
影响范围:
- app/services/dify-client.server.ts - 核心服务层
- app/routes/api.chat-messages.tsx - 聊天消息
- app/routes/api.parameters.tsx - 应用参数
- app/routes/api.conversations.tsx - 会话列表
- app/routes/api.messages.tsx - 消息历史
- app/routes/api.conversations.$id.tsx - 删除会话
- app/routes/api.conversations.$id.name.tsx - 重命名会话
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
|
2025-10-30 09:47:48 +08:00 |
|
PingChuan
|
6698542839
|
删除调试打印信息
|
2025-07-02 10:28:47 +08:00 |
|
pingchuan
|
ce851cc448
|
取消统一转发Dify请求,改为由客户端直接发送
|
2025-07-01 15:54:28 +08:00 |
|
pingchuan
|
13fb6ce79f
|
修复打包后读取不到.env文件,编写打包脚本
|
2025-06-09 14:48:58 +08:00 |
|
pingchuan
|
ab960f6dd0
|
移除聊天组件中的调试日志
|
2025-06-06 15:31:36 +08:00 |
|
pingchuan
|
1b79f973da
|
更新AI聊天页面样式
|
2025-06-06 15:07:57 +08:00 |
|
pingchuan
|
af33de09db
|
基于 shiy-temp分支修改
|
2025-06-04 11:18:52 +08:00 |
|