Basic Auth + Policies Help

Hey Everyone,

I am relatively new to web dev, so forgive me if I am doing something boneheaded here. To get acquainted with Supabase I am simply trying to achieve logging in with a script and inserting a row to the database with RLS on.

I am using nodeJS v18.9.0 with TypeScript 4.8.4 on a Mac on the desktop.

I made a table called 'testTable' that just has simple 'test' varchar column. I created a policy allowing "authenticated" users to Insert on the same table.

Here's what my TypeScript type looks like: https://pastebin.com/Eu63D34B

The error I keep getting is code 42501, 'new row violates row-level security policy for table "testTable"'.

Why am I posting here? I am unsure as to whether I am logging in correctly, and it could be as simple as that.

In the example code I pasted, am I logging in correctly? Do I need to store the users tokens or something that somewhere and pass them to the insert command somehow? Or is the supabase API taking care of all of that for me?

If I am logging in correctly then I guess I need advice on setting up the RLS policies.

Thanks for your time.
Ken
image.png
image.png
image.png
Pastebin
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Was this page helpful?