0

I'm using Expo + Supabase and recently switched from Expo Go to a custom development build using:

npx expo prebuild
npx expo run:ios

Since I'm using custom native modules that aren’t supported in Expo Go, I can’t use Expo Go anymore — I have to run my app in the custom dev client.

After switching, all Supabase network requests started failing on iOS simulator with this error:

(NOBRIDGE) ERROR  Error fetching initial session: Network request failed undefined  
(NOBRIDGE) ERROR  [TypeError: Network request failed]  
(NOBRIDGE) ERROR  [AuthRetryableFetchError: Network request failed]

Even when I switch the dev server host in the Expo Dev menu to http://localhost:8081 or my LAN IP (http://192.168.0.166:8081), the error still occurs. Everything worked fine before in Expo Go.

I expected the custom dev client to be able to connect to my Supabase backend just like Expo Go did.

What I’ve confirmed:

  • ✅ The project is running locally at http://192.168.0.166:8081
  • ✅ This URL in safari in the iOS Simulator does not throw this error and loads data (as evident in console logs but does not have any UI just the loading screen)
  • ✅ It worked in Expo Go before I installed the new dependencies
  • ❌ It fails in the dev client built with expo run:ios

This is how I’m setting up my Supabase client with SecureStore (I also need help figuring out how to keep the SecureStore under 2048b which Expo Go warned me about before I installed my native code library (rnmapbox)):

import { AppState } from 'react-native';
import 'react-native-url-polyfill/auto';
import * as SecureStore from 'expo-secure-store';
import { createClient } from '@supabase/supabase-js';

const supabaseUrl = process.env.EXPO_PUBLIC_SUPABASE_URL || '';
const supabaseAnonKey = process.env.EXPO_PUBLIC_SUPABASE_ANON_KEY || '';

const SecureStoreStorage = {
  async getItem(key: string) {
    return await SecureStore.getItemAsync(key);
  },
  async setItem(key: string, value: string) {
    await SecureStore.setItemAsync(key, value);
  },
  async removeItem(key: string) {
    await SecureStore.deleteItemAsync(key);
  },
};

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

AppState.addEventListener('change', (state) => {
  if (state === 'active') {
    supabase.auth.startAutoRefresh();
  } else {
    supabase.auth.stopAutoRefresh();
  }
});

File Tree:

├── .expo/
├── android/
├── app/
│   ├── _layout.tsx
│   ├── +not-found.tsx
│   ├── Home.tsx
│   ├── index.tsx
│   ├── orgView.tsx
│   ├── Register.tsx
│
├── assets/
│   └── images/
│
├── components/
├── ios/
├── lib/
├── node_modules/
├── .env
├── .gitignore
├── app.json
├── babel.config.js
├── components.json
├── eas.json
├── global.css
├── index.js
├── metro.config.js
├── nativewind-env.d.ts
├── package-lock.json
├── package.json
├── README.md
├── tailwind.config.js
└── tsconfig.json

UPDATE:

Got this error after it working once:

Failed to load app from http://192.0.0.2:8081 with
error: The resource could not be loaded because
the App Transport Security policy requires the use
of a secure connection.
1

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.