clerk / t3-turbo-and-clerk

A t3 Turbo starter with Clerk as the auth provider.
https://clerk.dev
1.03k stars 75 forks source link

Undefined user object from getAuth() #89

Open teddybee opened 1 year ago

teddybee commented 1 year ago

Describe the bug I am using t3-app and I would like to check the user's role in the trpc`s middleware. I added an auth object this way

const auth = getAuth(opts.req as RequestLike);

Unfortunately the user in the auth object is undefined. Is it a bug, or I need some additional coding to get the user object and role in privateMetadata? Is it the same issue in the next middleware, in the withClerkMiddleware() function.

const { user, userId,  } = getAuth(request);   

User object is undefined.

To Reproduce

Expected behavior User object is populated.

Logs Please provide logs showing the error.

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

Additional context