From 8099d333e446ed206b9e4aa1e8abb9cb3fe07d53 Mon Sep 17 00:00:00 2001 From: Wenyan Date: Thu, 30 Oct 2025 14:20:40 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=B3=E9=94=AE=E4=BF=AE=E5=A4=8D=EF=BC=9A?= =?UTF-8?q?=E7=A7=BB=E9=99=A4root.tsx=E4=B8=ADDify=E7=8E=AF=E5=A2=83?= =?UTF-8?q?=E5=8F=98=E9=87=8F=E6=B3=A8=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 问题:root.tsx 将 NEXT_PUBLIC_API_URL, NEXT_PUBLIC_APP_ID, NEXT_PUBLIC_APP_KEY 注入到客户端 window.__ENV,导致客户端 仍然使用环境变量中的 Dify 直连地址 修改: - 移除 ENV 对象中的所有 Dify 相关环境变量 - 客户端不再从 window.__ENV 读取 Dify 配置 - 确保客户端只使用 /api 路由 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- app/root.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/root.tsx b/app/root.tsx index c56ad81..ad87a5d 100644 --- a/app/root.tsx +++ b/app/root.tsx @@ -140,16 +140,16 @@ export async function loader({ request }: LoaderFunctionArgs) { responseHeaders["Set-Cookie"] = await sessionStorage.commitSession(refreshedSession); } - // 向组件传递认证状态、当前路径和环境变量 + // 向组件传递认证状态、当前路径 + // 注意:不再传递 Dify 相关环境变量,客户端改为调用 Remix API routes return Response.json({ isAuthenticated, userRole, pathname, frontendJWT, ENV: { - NEXT_PUBLIC_API_URL: process.env.NEXT_PUBLIC_API_URL, - NEXT_PUBLIC_APP_ID: process.env.NEXT_PUBLIC_APP_ID, - NEXT_PUBLIC_APP_KEY: process.env.NEXT_PUBLIC_APP_KEY, + // 移除 NEXT_PUBLIC_API_URL, NEXT_PUBLIC_APP_ID, NEXT_PUBLIC_APP_KEY + // 客户端不再需要直接调用 Dify API }, }, { headers: responseHeaders