I am working on Nextjs project with supabase client, when am trying to make api call to supabase client it show Unauthorize message.
Supabase Create Client Code:
import { createClient } from '@supabase/supabase-js'
const supabaseUrl = 'https://elkiggqnkibjbzgdfqrx.supabase.co'
const supabaseKey = process.env.NEXT_SUPABASE_API
export const supabase = createClient(supabaseUrl, `${supabaseKey}`)
Env file:
NEXT_SUPABASE_API=<supabase_key>
Client Error:
POST https://elkiggqnkibjbzgdfqrx.supabase.co/rest/v1/earlybird 401 (Unauthorized)
I try to access the supabase client object and make api calls to the postgress database which I gave the policy.
Database Policy:
alter policy "Enable insert for anon key only"
on "public"."earlybird"
to anon
with check (
true
);
The policy affect a database table with only {email}.
Table:
| id | create_at | |
|---|---|---|
| 0 | datetime | |
| .. | ..... | ......... |