Forráskód Böngészése

use factory-env in AuthContext

Ian Fung 1 éve
szülő
commit
2ebdd2e038
1 módosított fájl, 8 hozzáadás és 1 törlés
  1. 8 1
      context/AuthProvider.tsx

+ 8 - 1
context/AuthProvider.tsx

@@ -69,8 +69,15 @@ export default function AuthProvider({ children }: { children: ReactNode }) {
 
     const login = async (username: string, password: string) => {
         try {
+            const apiUrl = process.env.EXPO_PUBLIC_API_URL;
+            if (!apiUrl) {
+                throw new Error(
+                    'API URL is not defined in environment variables'
+                );
+            }
             const response = await axios.post(
-                'http://192.168.1.33:12000/api/v1/clients/customer/sign-in',
+                `${apiUrl}/clients/customer/sign-in`,
+                // 'http://192.168.1.33:12000/api/v1/clients/customer/sign-in',
                 {
                     email: username,
                     password: password