bradgarropy
02/28/2022, 5:57 AMtodos
table setup from the Supabase templates. I'd like users to be able to to all of the CRUD operations (INSERT
, SELECT
, UPDATE
, DELETE
) on their own data.
I've set up a table that looks like the one above, and set up RLS as shown above.
I'm running into an issue where a logged in user
is unable to SELECT
any data at all. There are no errors in the API request, just seeing an empty array []
for the returned data
object.
The only difference between my table and the example todos
table are a few of the column names, one of which being userId
in my table versus user_id
in the example table.
Could that make a difference? If so, why?
Here is my source code if you're interested in taking a peek.
https://github.com/bradgarropy/next-todogaryaustin
02/28/2022, 3:58 PMbradgarropy
02/28/2022, 4:40 PMauth.role() = 'authenticated"
and I was still not able to see any todo
items. I feel like I do have a logged in user
because I can see the supabase.auth.token
entry in local storage.
Switching over to auth.role() = 'anon'
allowed me to see all todo
items, even those that were not created by my user.
So, it's something about my user not being logged in, or not being passed along to supabase?
Does it matter what key I use when I create the supabase
client? Currently I'm using the public / anon
key.
Any other suggestions maybe?garyaustin
02/28/2022, 4:47 PMgaryaustin
02/28/2022, 4:51 PMbradgarropy
02/28/2022, 4:57 PMgetServerSideProps
)! There is no user present there at that time!
typescript
const {data: todos} = await supabase
.from<Todo>("todos")
.select("*")
.order("createdAt", {ascending: false})
bradgarropy
02/28/2022, 4:57 PMsupabase
calls from the server?garyaustin
02/28/2022, 5:00 PMbradgarropy
02/28/2022, 5:02 PM