From 215ecff41d245ec0283b18c289a14ccf2f852e79 Mon Sep 17 00:00:00 2001 From: Wenyan Date: Thu, 30 Oct 2025 14:39:52 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=EF=BC=9A=E6=81=A2=E5=A4=8DCH?= =?UTF-8?q?AT=5FCONFIG.APP=5FID=E5=92=8CAPI=5FKEY=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=EF=BC=8C=E8=A7=A3=E5=86=B3"=E5=BA=94=E7=94=A8=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E4=B8=8D=E6=AD=A3=E7=A1=AE"=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 问题:移除APP_ID和API_KEY后,chat/index.tsx第125行检查失败, 导致显示"应用暂时不可用,应用配置不正确" 修改: 1. app/config/chat.ts - 添加 APP_ID = 'docreview-chat' (用于localStorage key) - 添加 API_KEY = '' (空值,保持兼容性) - 说明:API_KEY不再用于直接调用Dify,服务端通过JWT处理 2. app/components/chat/index.tsx - 修改hasSetAppConfig检查:从检查APP_ID和API_KEY改为只检查API_URL - 说明:客户端现在通过Remix API routes调用,不需要验证API_KEY 调用流程保持不变: 客户端 → /api/* → JWT验证 → FastAPI /dify → Dify 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- app/components/chat/index.tsx | 5 +++-- app/config/chat.ts | 6 ++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/app/components/chat/index.tsx b/app/components/chat/index.tsx index e4fb0ed..66642e9 100644 --- a/app/components/chat/index.tsx +++ b/app/components/chat/index.tsx @@ -121,8 +121,9 @@ export default function Chat() { // 跟踪新对话是否已发送第一条消息 const [newConversationFirstMessageSent, setNewConversationFirstMessageSent] = useState>(new Set()); - // 检查应用配置 - const hasSetAppConfig = CHAT_CONFIG.APP_ID && CHAT_CONFIG.API_KEY; + // 检查应用配置 - 现在客户端通过Remix API routes调用,不需要APP_KEY + // 只检查API_URL是否配置 + const hasSetAppConfig = !!CHAT_CONFIG.API_URL; /** * 处理开始聊天 diff --git a/app/config/chat.ts b/app/config/chat.ts index 6930338..ec78ff2 100644 --- a/app/config/chat.ts +++ b/app/config/chat.ts @@ -42,6 +42,12 @@ export const CHAT_CONFIG = { // 客户端 → /api/* routes → dify-client.server.ts → FastAPI /dify → Dify API_URL: getApiBaseUrl(), + // 应用ID - 用于localStorage key(固定值) + APP_ID: 'docreview-chat', + + // API_KEY 不再需要 - 服务端通过JWT处理认证 + API_KEY: '', // 保留字段以兼容旧代码 + // 应用信息 APP_INFO: { title: '大模型对话',