Query supabase in next server api
Hello, im quite a newbe for both Supabase, Refine and Next.js
I have this simple file called
api/messages.ts
the file looks like:
and im getting the following error:
@auth/context/supabase/lib
i can query the database using supabase.from(.... but i want to query the database with the user permissions (because im using postgres RLS).
what should i do next?
thanks.2 Replies
Hi @nirberko. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
I'm sorry, but the information provided in the knowledge sources does not include specific instructions on how to query a Supabase database with user permissions using Next.js. The knowledge sources provided are focused on using Supabase with Refine, a React-based framework, and do not mention Next.js.
However, in Refine, user roles are fetched by
authProvider
's getPermissions()
method. It is already defined for us by @refinedev/supabase
. The default getPermissions
method in authProvider
looks like this:
This might give you a hint on how to proceed with your Next.js application. You might need to ensure that the user session is properly set up before making the query.
For more specific guidance, I would recommend checking the official Supabase and Next.js documentation or their respective communities.
Sources:
- User Permissions with Supabase in Refine (https://refine.dev/blog/refine-pixels-6#user-permissions-with-supabase-in-refine)
- Supabase Data Provider (https://refine.dev/docs/data/packages/supabase#register-supabase-data-provider)
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@508352015840182282> kapa.ai is still learning and improving, please let us know how it did by reacting below