You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is more of a question rather than a bug (yet), so I'll omit the reproduction for now.
Describe the bug
Hi, I'm using Nuxt 3, tRPC, Prisma and Nuxt-Auth with a custom OAuth provider. When using the default providers, it's stated in the docs that we need to use the <provider>.default({...}), but what about custom providers? The comment states // @ts-expect-error You need to use .default here for it to work during SSR. May be fixed via Vite at some point and I think I'm getting a session SSR issue. I can log in and log out, but with an authMiddleware in tRPC like following
const authMiddleware = t.middleware(({ ctx, next }) => {
if (!ctx.session?.user) {
throw new TRPCError({ code: 'UNAUTHORIZED' });
}
return next({
ctx: {
// infers the `session` as non-nullable
session: { ...ctx.session, user: ctx.session.user }
}
});
});
For every call to a authMiddleware procedure, I get an UNAUTHORIZED, even when I am logged in and have the correct tokens in my session / cookie.
But here is the weird thing: whenever editing anything on the client-side of the app and hot reload, those auth protected calls suddenly work (only one call though). This is why I think this issue is related to the <provider>.default({...}) part.
I'm not sure whether this is a bug (not even this package, might also be tRPC-Nuxt) or a mistake on my part. If this is a bug I will investigate further and file a proper bug report.
Seems like I had a wrong configuration for my tRPC Plugin. I was importing httpBatchLink from @trpc/client instead of from trpc-nuxt/client. But my question about custom providers still stands because it was quite unclear from the docs.
Environment
Reproduction
This is more of a question rather than a bug (yet), so I'll omit the reproduction for now.
Describe the bug
Hi, I'm using Nuxt 3, tRPC, Prisma and Nuxt-Auth with a custom OAuth provider. When using the default providers, it's stated in the docs that we need to use the
<provider>.default({...})
, but what about custom providers? The comment states// @ts-expect-error You need to use .default here for it to work during SSR. May be fixed via Vite at some point
and I think I'm getting a session SSR issue. I can log in and log out, but with an authMiddleware in tRPC like followingFor every call to a
authMiddleware
procedure, I get an UNAUTHORIZED, even when I am logged in and have the correct tokens in my session / cookie.But here is the weird thing: whenever editing anything on the client-side of the app and hot reload, those auth protected calls suddenly work (only one call though). This is why I think this issue is related to the
<provider>.default({...})
part.I'm not sure whether this is a bug (not even this package, might also be tRPC-Nuxt) or a mistake on my part. If this is a bug I will investigate further and file a proper bug report.
Additional context
server/api/auth/[...].ts
No response
Logs
No response
The text was updated successfully, but these errors were encountered: