RLS is disabled. Role is anon. Seems like that the necessity right? This is my code using nextjs. I made it works previously, but not sure why it doesn't work now.
const fetchSupabaseUser = async (firebaseUser: FirebaseUser | null) => {
      if (!firebaseUser) return;
      const { data, error, status } = await supabase
        .from('users')
        .select('*')
        .eq('google_id', firebaseUser.uid)
        .single();
      console.log(error, status);
      if (error && status !== 406) {
          console.error("Supabase error:", error);
          throw error
      }
      // if (error) console.error("Supabase error:", error);
      
      if (error && Object.keys(error).length !== 0) {
          if (error instanceof Error) {
              console.error('Error fetching Supabase user:', error.message);
          // } else {
          //   console.error('An unknown error occurred while fetching Supabase user:', error);
          }
          return;
      }
      setUser(data);
      console.log('Supabase user set:', data);
};
In the Chrome console, I see this:
fetch.ts:15 GET https://mkibhcvvghfyxutpsaqe.supabase.co/rest/v1/users?select=*&google_id=eq.mbRwFh8AgLZuSaXCscIIkJNFTBz1 406 (Not Acceptable)
Printing the error:
{
code: 'PGRST116',
details: 'The result contains 0 rows',
hint: null,
message: 'JSON object requested, multiple (or no) rows returned'
}
Sorry, fixed it. single() will return error if empty (but the error code really misguided). so using maybeSingle() solved this
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With