clean-aquamarineC
Refine2y ago
3 replies
clean-aquamarine

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:
import { supabase } from "@auth/context/supabase/lib";

export async function sendMessage() {
  const user = await supabase.auth.getUser();

  console.log(user);
}


and im getting the following error:

AuthSessionMissingError: Auth session missing!


@auth/context/supabase/lib
import { createClient } from "@supabase/supabase-js";

import { SUPABASE_API } from "@config-global";

export const supabase = createClient(
  `${SUPABASE_API.url}`,
  `${SUPABASE_API.key}`,
);


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.
Was this page helpful?