0

I'm new to Supabase and experimenting with building a new Next.js app using it. Below are the steps that I've taken thus far that led to the error:

I initialized a fresh Next.js app using npx create-next-app I installed Supabase using npm i @supabase/supabase-js. I created a .env.local file and added my Supabase database API URL and anon key as NEXT_PUBLIC environment variables. I initialized Supabase in a /util/supabase.js file with the following code:


const supabaseUrl = process.env.NEXT_PUBLIC_SUPABASE_URL;
const supabaseAnonKey = process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY;

export const supabase = createClient(supabaseUrl, supabaseAnonKey);

I attempt to query my "Course" database table using the following code in my /pages/index.js file:

import { supabase } from "../lib/supabaseClient";

export default function HomePage({ courses }) {
  return <div>Under Construction...</div>;
}

export async function getStaticProps() {
  const { data, error } = await supabase.from("course").select("*");
  console.log(data, error);

  return {
    props: {
      courses: data,
    },
  };
}

When I do the above, however, I get error 42501: "Permission denied for schema public."

I recognize that I'm doing something wrong here, but I've read through the docs and I have no idea what it is. Since this is my very first experience with Supabase, I'd very much appreciate any help that someone can provide about what I need to do differently to get things going.

Thanks very much, Sulaim

sulaim
  • 1
  • 1
  • How did you create the tables? From the error message, it looks like you have removed the permission to access the public schema, but did you do anything from the SQL editor? In your case, it might be easier to start out with a fresh new Supabase project! – dshukertjr Oct 17 '22 at 06:32

1 Answers1

0

I had the same error, in my case editing table setting in Supabase table editor worked. I unchecked "Enable Row Level Security (RLS)".

jemjasott
  • 1
  • 1
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Nov 13 '22 at 14:21