0

I am trying to connect a react native app to a local Supabase development set up. I am doing so using the localhost API url and the provided anon key:

const supabaseUrl = 'http://localhost:54321'
const supabaseAnonKey = 'my anon key'

export const supabase = createClient(supabaseUrl, supabaseAnonKey, {
  auth: {
    storage: new LargeSecureStore(),
    autoRefreshToken: true,
    persistSession: true,
    detectSessionInUrl: false,
  },
});

However, when I try to make any requests to my local server, e.g. returning table information or signing up I get the error: 'TypeError: Network request failed'

const { data, error } = await supabase.from("test").select("*");
> 'TypeError: Network request failed'

Replacing the supabaseUrl and supabaseAnonKey with their values from my online project functions as usual. Making the same request through the terminal does return results.

curl 'http://localhost:54321/rest/v1/test' \
-H "apikey: my anon key" \
-H "Authorization: Bearer my anon key"

>[{"id":1,"created_at":"2023-10-19T09:31:05.307966+00:00"}]

Anyone know what the issue could potentially be?

1 Answer 1

0

Never mind - figured it out, as I was connecting through my phone on expo I needed to replace localhost with my local machine ip.

Sign up to request clarification or add additional context in comments.

Comments

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.