Use this file to discover all available pages before exploring further.
All network requests in Panahashi Baker go through a single ApiService class defined in src/services/api.js. Before you run the app against a real server, you need to update one constant with your backend’s URL. Everything else — auth headers, error handling, and endpoint routing — is already wired up.
The first line you need to change is the API_BASE constant at the top of src/services/api.js:
const API_BASE = "http://10.0.2.2:8080/api/v1"; // 👈 Cambia esto
Replace the value with the base URL of your deployed backend, for example https://api.yourbakery.com/api/v1.
10.0.2.2 is the Android emulator’s alias for localhost on your development machine. It works when you run the app in Android Studio’s emulator against a local server, but it will not reach a remote server and it does not work on a physical device or in iOS Simulator. Change this to your real URL before running on a device or building for production.
To avoid hard-coding the URL, add it to a .env file in the project root and read it via expo-constants (already in package.json). Create .env:
API_BASE=https://api.yourbakery.com/api/v1
Then in src/services/api.js, replace the constant with:
import Constants from "expo-constants";const API_BASE = Constants.expoConfig?.extra?.apiBase ?? "http://10.0.2.2:8080/api/v1";
And expose the variable in app.json under expo.extra.apiBase.
You do not call api.setToken() yourself. The onAuthStateChanged listener in src/services/auth.js calls it automatically whenever the auth state changes:
If the server returns a 401 Unauthorized response, call() throws new Error("NO_AUTH"). You can catch this error anywhere in your screens to redirect the user to the login screen:
try { const bakery = await api.getBakery();} catch (err) { if (err.message === "NO_AUTH") { // Token expired or revoked — send the user back to login }}