Closed C-Johanson closed 5 months ago
@C-Johanson that's indeed strange, i'm unable to reproduce this - do you happen to have a repo that i can clone to see what's going wrong here?
also, have you tried console logging the supabase
object returned from getServerClient()
as a sanity check ?
'use server'
- it looks like the problem , could you remove this?
I may have misunderstood what is going on, but it looks like you're trying to return a Supabase client from a Server Actions. This is not possible as it is too complex an object to be serialized. Additionally, you need to create the Supabase client from the scope of the Server Component as calling the cookies
function at this level signals to Next.js that this route is dynamic.
Shorter answer: there is a lot of configuration that needs to line up perfectly. Therefore, we recommend using the with-supabase template for all Next.js and Supabase projects. This can be used when creating a new project with create-next-app
:
npx create-next-app@latest -e with-supabase
The main benefit of using this as a starting point, is all of the server-side auth and PKCE stuff is already configured for you.
Bug report
Describe the bug
I have a project on Nextjs 14.0.3 with a working supabase auth flow, setting and reading cookies fine. I started a new nextjs project with create-next-app@latest and Next seesm to have pushed a new ver. After setting up all of the supabase auth identically to the project before, I kept getting this error using @supabase/ssr
getServerClient() is as follows:
and this is the function throwing the error:
To Reproduce
Steps to reproduce the behavior, please provide code snippets or a repository:
Expected behavior
Expected to be able to get auth client from supabse
Screenshots
If applicable, add screenshots to help explain your problem.
System information