Convex+Clerk lack of Auth within preloadQuery
I'm getting a strange error when using
preloadQuery
, where there is no authentication.
Use of preloadQuery:
api.db.players.getCampaigns
:
This was working perfectly when I was just using useQuery
within my Client-rendered <CampaignPageContent>
component.
Any thoughts / advice?4 Replies
I would have thought that the
auth()
call returning a successful userId would mean the convex integration was going to work 🤔Now that I've documented this, I note my one other server-side NextJS component that's trying to do Convex stuff is also failing:
Component
Mutation
Take a look at https://docs.convex.dev/client/react/nextjs/server-rendering#server-side-authentication -- I believe you need to pass your auth token to the
preloadedQuery
/ fetchMutation
calls explicitlyNext.js Server Rendering | Convex Developer Hub
Next.js automatically renders both Client and Server Components on the server
😮
Oh my lord, you're a star! Thanks @sshader