28 Replies
I've got the invite into the org but there're many repos in it. Could you let me know which one I should look into @markit97212 ?
Unknown UserOP•14mo ago
Message Not Public
Sign In & Join Server To View
Got it. I’ll look into it and get back to you
Just to make sure, I should use "dev" branch, right?
I'm still having trouble to get to the point where ZenStack runtime fails ... but here are some observations:
1. I see that you're using next13 app dir, in that case, the "@zenstackhq/runtime" package needs to be excluded from Next.js's RSC bundler. https://nextjs.org/docs/app/api-reference/next-config-js/serverComponentsExternalPackages
2. I tried to add the above setting into the ESM version of your next.config.js, but it doesn't seem to be effective. I had to convert it to a CJS to let Next.js pick up the settings. Don't know why ...
After the changes, when I ran "npm run dev" and hit "localhost:3000/signup", I see the following trpc errors:
I figured trpc support is non-official for app dir. Did trpc work in your environment?
Unknown UserOP•14mo ago
Message Not Public
Sign In & Join Server To View
Hi @markit , I can see the error now. It seems to be related to that "serverComponentsExternalPackages" in "next.config.cjs" is not effective. After changing it to a esm, the problem seems gone.
Could you try if you see the same thing by replacing "next.config.cjs" with this file?
The "@zenstackhq/runtime" package has to be excluded by the nextjs server components bundler
Unknown UserOP•14mo ago
Message Not Public
Sign In & Join Server To View
Yes, I ran the app and hit http://localhost:3000/api/trpc/getTodos
I saw a different error but not the $Schema undefined anymore
I'm working on a separate sample project with nextjs13 + app dir + trpc
Unknown UserOP•14mo ago
Message Not Public
Sign In & Join Server To View
https://github.com/zenstackhq/sample-blog-nextjs-app-trpc
Here you go, it's a blog app made with:
- create-t3-app
- Next.js 13 app dir
- NextAuth
- trpc
GitHub
GitHub - zenstackhq/sample-blog-nextjs-app-trpc: Blog Sample Using ...
Blog Sample Using Next.js 13 App Route and TRPC. Contribute to zenstackhq/sample-blog-nextjs-app-trpc development by creating an account on GitHub.
Hi @afusco , I'm not sure if you're using a similar stack, but the sample 👆🏻 might be useful
Unknown UserOP•14mo ago
Message Not Public
Sign In & Join Server To View
Let me include this as a sample to github readme and doc site so more people can find it 😄
I'm so glad you find ZenStack helpful. Yes, good idea, we should reach out to Theo and see if he's interested in including it into t3. It's stable enough now.
Unknown UserOP•14mo ago
Message Not Public
Sign In & Join Server To View
Got it. Ya, I believe there's something intricate going on. A repro would be very helpful! Thanks!
Unknown UserOP•11mo ago
Message Not Public
Sign In & Join Server To View
Hi @Alex , we don’t have one yet. Have you already created such a project? I’d be happy to see how I can help.
Unknown UserOP•11mo ago
Message Not Public
Sign In & Join Server To View
Sure. Thank you!
Unknown UserOP•11mo ago
Message Not Public
Sign In & Join Server To View
Hi @Alex , I tried running the code and found the
authUser
passed to enhance
call is undefined. If that's the case, the enhanced client will run as anonymous user.
I checked Clerk's doc, the response of getAuth()
API doesn't include a "user" field. https://clerk.com/docs/references/nextjs/authentication-object
Have you checked if it's the same on your side? I'm not an expert with Clerk, but it seems that if you need to access additional metadata in the backend, you need to include them into the session token with a template: https://clerk.com/docs/backend-requests/making/custom-session-tokenhttps://clerk.com/docs/backend-requests/making/custom-session-tokenAuthentication Object | Clerk
The Authentication object contains information about the current user's session.
I don't see any rules in schema.zmodel referencing "roles" field, but I guess you have plan for the future.
Unknown UserOP•11mo ago
Message Not Public
Sign In & Join Server To View
You're welcome. If you only need to check with user id in the policy rules in zmodel, you can simply call
enhance
like:
Unknown UserOP•11mo ago
Message Not Public
Sign In & Join Server To View
Awesome! Great to know that.