From 68271c08462686b562d7b688d2bd3342fa43842f Mon Sep 17 00:00:00 2001 From: John Chen Date: Wed, 22 Oct 2025 16:17:42 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8DPlugin=E4=BB=A3?= =?UTF-8?q?=E7=90=86=E6=9C=8D=E5=8A=A1=E5=9C=A8=E5=A4=84=E7=90=86=E9=80=9A?= =?UTF-8?q?=E8=BF=87nginx=E8=BD=AC=E5=8F=91=E9=83=A8=E7=BD=B2=E7=9A=84Plug?= =?UTF-8?q?in=E6=9C=8D=E5=8A=A1=E6=97=B6=EF=BC=8Creq.headers=E4=B8=AD?= =?UTF-8?q?=E7=9A=84host=E4=BC=9A=E5=AF=BC=E8=87=B4=E8=BF=94=E5=9B=9E404.?= =?UTF-8?q?=20(#5801)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 问题场景: 当Plugin服务不是直接通过ip\docker内路由直接访问,而是通过nginx做域名转发的方式部署时,30行headers: req.headers会直接将host(此时host=fastgpt主项目的域名)带入,nginx会使用host值判断转发路由,而导致请求无法被正确转发到plugin项目中。 此次修改参照了projects/app/src/pages/api/lafApi/[...path].ts中的做法,同时删除了cookie\host\origin三个header --- projects/app/src/pages/api/system/plugin/[...path].ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/projects/app/src/pages/api/system/plugin/[...path].ts b/projects/app/src/pages/api/system/plugin/[...path].ts index d0744b87a8..c82dac8775 100644 --- a/projects/app/src/pages/api/system/plugin/[...path].ts +++ b/projects/app/src/pages/api/system/plugin/[...path].ts @@ -17,6 +17,9 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse) const parsedUrl = new URL(FastGPTPluginUrl); delete req.headers?.rootkey; + delete req.headers?.cookie; + delete req.headers?.host; + delete req.headers?.origin; const requestResult = request({ protocol: parsedUrl.protocol,