0

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 email create_at
0 email datetime
.. ..... .........
2

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.