create-t3-app: bug: Recent Commit Breaks Clerk Based Authentication w/ tRPC
Provide environment information
“initVersion”: “7.23.2”
System: OS: Linux 5.15 Ubuntu 20.04.6 LTS (Focal Fossa) CPU: (16) x64 Intel® Core™ i7-10700 CPU @ 2.90GHz Memory: 9.02 GB / 15.58 GB Container: Yes Shell: 5.8 - /usr/bin/zsh Binaries: Node: 18.18.0 - ~/.nvm/versions/node/v18.18.0/bin/node Yarn: 1.22.17 - ~/.yarn/bin/yarn npm: 10.1.0 - ~/.nvm/versions/node/v18.18.0/bin/npm pnpm: 8.9.2 - ~/.local/share/pnpm/pnpm bun: 1.0.7 - ~/.bun/bin/bun
Describe the bug
I’ve encountered an issue with the recent changes introduced in commit e6649f18963086b2d016815e60cc9915711a85d8. These changes appear to have broken the Clerk based authentication, which in turn is affecting the functionality of tRPC in my application.
Reproduction repo
https://github.com/Jacksonmills/gpts-browser
To reproduce
To reproduce, revert the changes back to main in this commit e6649f18963086b2d016815e60cc9915711a85d8. Once reverted, log in with Clerk and visit a page with a query to get:
Unhandled Runtime Error
Error: Cannot read properties of undefined (reading 'resolve')
Additional information
I was able to revert the changes in the problematic commit, which fixes all my issues. However, I would love if someone could further explain or suggest how we can go back to using cookies while also making Clerk work. That would be ideal! Thank you. 👏
About this issue
- Original URL
- State: closed
- Created 8 months ago
- Reactions: 3
- Comments: 18 (8 by maintainers)
@bhatvikrant Use the
authfunction instead ofgetAuth()which will not require the req parameterhttps://clerk.com/docs/references/nextjs/auth#auth
“initVersion”: “7.24.1”
Ik this issue is closed but I am facing the following error:
I am using clerk with the latest version of T3, App router.
Contents of my
trpc.tsfile are:as soon as I make this change I start getting errors in
src/trpc/server.tsandsrc/app/api/trpc/[trpc]/route.tssrc/trpc/server.ts filesrc/trpc/server.ts errorsrc/app/api/trpc/[trpc]/route.ts filesrc/app/api/trpc/[trpc]/route.ts errorNot sure what is wrong here, I followed the clerk docs for integrating with trpc
@juliusmarminge @JacobMGEvans @Jacksonmills
Hey @eula01, which community are you referring to? In Clerk we are addressing this tRPC issue and @royanger is working on definitive workarounds. If there is something in particular we haven’t addressed or you have additional concerns, please let us know.
@Jacksonmills I appreciate you bringing this up here and in Clerk, we will be collaborating with Julius and potentially tRPC members as well if necessary to find the right pattern/workaround, and then find the best path forward from there for a more permanent solution.
clerk is still broken + unuseable with next app router + trpc – unreal that this has been getting 0 attention in the community
same problem here. Had to make the reversion mentioned above.
Looks like Clerk requires a bunch of headers…
https://github.com/clerk/javascript/blob/dde4399b5ea2ac30b0a066f3f97c90dabf6038ee/packages/backend/src/constants.ts#L20C10-L36
I had the same issue because Clerk was not happy that the user agent was missing after transitioning from headers to cookies only. I fixed it for now by including the bearer token in
server.ts.@imopbuilder thank you for this note ^ It was super helpful! 🙌
Nice @Arechii this worked for me, much easier than fully reverting the previous commit. I wonder… is this a potential long term fix? Also don’t forget to add to your
server.tsasw asreact.tsx@t3dotgg please be aware of this when shilling clerk – unuseable DX – clerk is fundamentally broken + incompatible with trpc & app router – and clerk devs have been radio silent for >2 months – 100s and 100s of comments and discussions on clerk discord and nothing!
Does anyone have a good working version of a simple server/api/trpc.ts which incorporates clerk? most of the docs floating around have not kept up with a myriad of changes, and I am still trying to wrap my head around combining numerous items into inner/outer context. TIA.
In the meantime if you just revert the changes from the linked commit Clerk will work fine
Hitting the same issue.