Skip to content
This repository was archived by the owner on Oct 29, 2024. It is now read-only.
This repository was archived by the owner on Oct 29, 2024. It is now read-only.

Undefined user object from getAuth() #89

Description

@teddybee

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):

  • OS: windows 11
  • Browser chrome
  • Version 117
  • NodeJS 20.6.3
  • Nextjs 13.5.2
  • CreateT3app 7.20.2
  • "@trpc/server": "^10.38.3",
  • "@clerk/nextjs": "^4.24.0",

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions