#Convex Auth state issue

1 messages · Page 1 of 1 (latest)

north hornetBOT
#

Thanks for posting in #1088161997662724167.
Reminder: If you have a Convex Pro account, use the Convex Dashboard to file support tickets.

  • Provide context: What are you trying to achieve, what is the end-user interaction, what are you seeing? (full error message, command output, etc.)
  • Use search.convex.dev to search Docs, Stack, and Discord all at once.
  • Additionally, you can post your questions in the Convex Community's #1228095053885476985 channel to receive a response from AI.
  • Avoid tagging staff unless specifically instructed.

Thank you!

viscid monolith
mental lantern
#

I did setup a custom auth provider with ConvexCredentials
all I am doing is returning a hardcoded user ID

return {
  userId: "jx7d53dc0rnbv0ptkmb30yz41172dxsd" as Id<"users">,
}                }

I have my app wrapped with ConvexAuthNextjsProvider

When I am calling signIn from useAuthActions, it is signing in but I am getting this error:

Error: Invariant: cookies() expects to have requestAsyncStorage, none available.
    at Module.cookies (headers.ts:41:11)
    at invalidateCache (invalidateCache.js:6:5)
    at client.js:47:19
    at async client.js:127:13
    at async testAuth (protected-content.tsx:40:3)
#

also when i log out, the states doesn't change (Authenticated component, etc...)

#

another thing:
the react ConvexAuthProvider works great, it is signing in with no issues, the states are changing perfectly when I login or logout. the only issue there is it is not saving the tokens to cookies. which makes sense.
I guess the problem might be with ConvexAuthNextjsProvider ?

viscid monolith
#

What version of Next.js are you using here? ANd what does protected-content.tsx look like (it almost sounds like we're trying to fetch auth as if we're in a server request but during a client render)

mental lantern
#

I don’t have my computer in front of me, I’ll check the next version asap.

#

The protected is more of a “Authed only” client component that renders a button if you are not authenticated, to ask people to authenticate before completing any action that requires the user to be authenticated.

viscid monolith
#

An error from a client component about reading cookies sounds like you might be calling the server only functionsconvexAuthNextjsToken or isAuthenticatedNextjs from the client instead of using useConvexAuth or <Authenticated> components