From 00fa228a3009a51c9cf5ad999874d41109b65b8b Mon Sep 17 00:00:00 2001 From: Gaubee Date: Wed, 21 Jan 2026 23:54:30 +0800 Subject: [PATCH] fix(wujie): preserve request headers in fetch interceptor The fetch interceptor was losing custom headers (like tRPC's trpc-accept) when rewriting URLs. This caused tRPC streaming responses to fail in wujie containers while working correctly in standalone mode. Fix: Use new Request(rewrittenUrl, req) to preserve the original request's complete configuration including headers. --- src/services/miniapp-runtime/container/wujie-container.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/services/miniapp-runtime/container/wujie-container.ts b/src/services/miniapp-runtime/container/wujie-container.ts index fc24d722a..f5be8db52 100644 --- a/src/services/miniapp-runtime/container/wujie-container.ts +++ b/src/services/miniapp-runtime/container/wujie-container.ts @@ -77,7 +77,9 @@ function createAbsolutePathRewriter(baseUrl: string) { } const rewrittenUrl = normalized.href.replace(PLACEHOLDER_ORIGIN, targetBaseHref); - return window.fetch(rewrittenUrl, init); + // 使用原始 Request 对象的完整配置(包括 headers),仅替换 URL + // 这确保 tRPC 的 trpc-accept 等自定义头不会丢失 + return window.fetch(new Request(rewrittenUrl, req)); }, plugins: [ {