Open yudistiraashadi opened 2 days ago
Thanks for opening the issue @yudistiraashadi!
Can you describe in more detail your use case for wanting to cache a function that uses createServerClient
?
createServerClient
uses the request cookies to authenticate the Supabase request as the requesting user, and you would in general very much not want to cache this, since that would run the risk of leaking user data across requests. Looking at your example, it looks like you might be using this to fetch data that is available to any authenticated user, in which case you could just use a normal Supabase client authenticated with your service role key (assuming this is in backend code only).
Thanks for opening the issue @yudistiraashadi!
Can you describe in more detail your use case for wanting to cache a function that uses
createServerClient
?
createServerClient
uses the request cookies to authenticate the Supabase request as the requesting user, and you would in general very much not want to cache this, since that would run the risk of leaking user data across requests. Looking at your example, it looks like you might be using this to fetch data that is available to any authenticated user, in which case you could just use a normal Supabase client authenticated with your service role key (assuming this is in backend code only).
Yes, normally, I would like to use it to fetch data on the server side. Isn't the cookies param required for createServerClient()
? How can I create createServerClient()
without passing cookies?
Bug report
Describe the bug
Unable to use
"use cache"
withcreateServerClient()
. Example code:To Reproduce
Steps to reproduce the behavior, please provide code snippets or a repository:
next.config.ts
Expected behavior
I hope to be able to use
use cache
with server side supabase data fetching.Additional context
Next.js docs regarding this topic here