mirror of
https://github.com/lobehub/lobehub.git
synced 2026-03-27 13:29:15 +07:00
🐛 fix: when use trpc client should include the credentials cookies (#11629)
fix: when use trpc client should include the credentials cookies
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user