Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

🐛 fix: when use trpc client should include the credentials cookies (#11629)

Shinji-Li8ece55355504
diff --git a/src/libs/trpc/client/lambda.ts b/src/libs/trpc/client/lambda.ts
index b41f569392f..19229ffa5e5 100644
--- a/src/libs/trpc/client/lambda.ts
+++ b/src/libs/trpc/client/lambda.ts
@@ -77,15 +77,22 @@ const errorHandlingLink: TRPCLink<LambdaRouter> = () => {
const linkOptions = {
// eslint-disable-next-line no-undef
fetch: async (input: RequestInfo | URL, init?: RequestInit) => {
+ // Ensure credentials are included to send cookies (like mp_token)
+ // eslint-disable-next-line no-undef
+ const fetchOptions: RequestInit = {
+ ...init,
+ credentials: 'include',
+ };
+
if (isDesktop) {
// eslint-disable-next-line no-undef
- const res = await fetch(input as string, init as RequestInit);
+ const res = await fetch(input as string, fetchOptions);
if (res) return res;
}
// eslint-disable-next-line no-undef
- return await fetch(input, init as RequestInit);
+ return await fetch(input, fetchOptions);
},
headers: async () => {
// dynamic import to avoid circular dependency