CraftzCode
CraftzCode5d ago

Troubleshooting createTRPCOptionsProxy with Server Components and Context Passing

How does createTRPCOptionsProxy work in server components? I'm creating a context that passes the hono context to createTRPCContext in order to obtain the HTTP headers, since I need to forward those headers to the better-auth API to get the session I use @hono/trpc-server which created by the hono so I can use hono as adapter of trpc.
Type '(c: HonoContext) => Promise<{ session: { session: { id: string; createdAt: Date; updatedAt: Date; userId: string; expiresAt: Date; token: string; ipAddress?: string | null | undefined | undefined; userAgent?: string | null | undefined | undefined; }; user: { ...; }; } | null; }>' is not assignable to type '{ session: { session: { id: string; createdAt: Date; updatedAt: Date; userId: string; expiresAt: Date; token: string; ipAddress?: string | null | undefined; userAgent?: string | null | undefined; }; user: { ...; }; } | null; } | (() => MaybePromise<...>)'.
Type '(c: HonoContext) => Promise<{ session: { session: { id: string; createdAt: Date; updatedAt: Date; userId: string; expiresAt: Date; token: string; ipAddress?: string | null | undefined | undefined; userAgent?: string | null | undefined | undefined; }; user: { ...; }; } | null; }>' is not assignable to type '() => MaybePromise<{ session: { session: { id: string; createdAt: Date; updatedAt: Date; userId: string; expiresAt: Date; token: string; ipAddress?: string | null | undefined; userAgent?: string | ... 1 more ... | undefined; }; user: { ...; }; } | null; }>'.
Target signature provides too few arguments. Expected 1 or more, but got 0.
Type '(c: HonoContext) => Promise<{ session: { session: { id: string; createdAt: Date; updatedAt: Date; userId: string; expiresAt: Date; token: string; ipAddress?: string | null | undefined | undefined; userAgent?: string | null | undefined | undefined; }; user: { ...; }; } | null; }>' is not assignable to type '{ session: { session: { id: string; createdAt: Date; updatedAt: Date; userId: string; expiresAt: Date; token: string; ipAddress?: string | null | undefined; userAgent?: string | null | undefined; }; user: { ...; }; } | null; } | (() => MaybePromise<...>)'.
Type '(c: HonoContext) => Promise<{ session: { session: { id: string; createdAt: Date; updatedAt: Date; userId: string; expiresAt: Date; token: string; ipAddress?: string | null | undefined | undefined; userAgent?: string | null | undefined | undefined; }; user: { ...; }; } | null; }>' is not assignable to type '() => MaybePromise<{ session: { session: { id: string; createdAt: Date; updatedAt: Date; userId: string; expiresAt: Date; token: string; ipAddress?: string | null | undefined; userAgent?: string | ... 1 more ... | undefined; }; user: { ...; }; } | null; }>'.
Target signature provides too few arguments. Expected 1 or more, but got 0.
Is there any solution to this issue so that I can pass my createTRPCContext properly?
No description
No description
No description
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?