App & API Configuration
Connect your FoodFeast Flutter Customer App to your deployed Laravel backend in less than 2 minutes by updating the API and media storage base URL constants.
App & API Configuration
Connect your FoodFeast Flutter Customer App to your deployed Laravel backend in less than 2 minutes by updating the API and media storage base URL constants.
Table of Contents
Architecture Overview#
The FoodFeast Customer Mobile App communicates with your Laravel backend using the high-performance Dio ^5.7.0 HTTP client with interceptors, token caching, and automated error recovery.
You never have to hunt through hundreds of Dart files to change API endpoints. All network requests and image loading pipelines are governed by two constants in a single file.
Configuring App Constants (baseUrl & baseUrl1)#
Open the Flutter project in your IDE (VS Code or Android Studio) and locate the constants file:
Source_Code/Foodfeast_user_app/lib/app/constants/app_constants.dartclass AppConstants {
/// Replace with your deployed backend API URL (must end with `/api/`)
static const baseUrl = "https://yourdomain.com/api/";
/// Replace with your backend storage media URL (must end with `/storage/`)
static const baseUrl1 = "https://yourdomain.com/storage/";
// Core endpoints (automatically managed by FoodFeast)
static const businessSettings = "business-settings";
static const login = "login";
static const signUp = "sendRegistrationCode";
static const verifyOtp = "verifyRegistrationCode";
static const categories = "categories";
static const stores = "stores";
static const products = "products";
static const banners = "banners";
static const cart = "cart";
static const checkout = "checkout";
static const myOrders = "my-orders";
}
- HTTPS Required: Both Android 9+ and iOS 12+ enforce secure Transport Layer Security (TLS/HTTPS). Production release builds will reject plain
http://URLs. - Trailing Slash Required: Both
baseUrl(ending in/api/) andbaseUrl1(ending in/storage/) must have a trailing slash. Dio uses standard URI resolution and omits relative segments without the trailing slash.
Recompile App with Clean State
Whenever you update app_constants.dart, run the following commands in the Flutter project directory to purge any cached build state:
cd Source_Code/Foodfeast_user_app
flutter clean
flutter pub get
flutter run
Verifying API Connectivity (business-settings)#
Before launching the app on a physical device, verify that your Laravel backend is properly responding to REST API queries.
Test in Browser or Postman
Navigate in your browser to:
https://yourdomain.com/api/business-settings
You should immediately receive a valid JSON response containing platform configuration, currency format, and tax rates:
{
"status": true,
"message": "Business settings retrieved successfully",
"data": {
"currency_symbol": "$",
"currency_position": "left",
"delivery_charge": "5.00",
"order_commission": "10",
"maintenance_mode": 0
}
}
If you see the JSON response above, your Laravel routing, database connection, and PHP environment are fully synced and ready to serve mobile clients!
Core REST API Endpoints#
All endpoints are relative to your configured baseUrl:
| Endpoint | HTTP Method | Functionality |
|---|---|---|
{baseUrl}business-settings |
GET | System configuration, active payment gateways, tax and currency rules |
{baseUrl}login |
POST | Customer authentication returning Bearer Sanctum API token |
{baseUrl}sendRegistrationCode |
POST | Sends SMS / Email OTP verification code for customer registration |
{baseUrl}verifyRegistrationCode |
POST | Validates OTP code and issues customer account session |
{baseUrl}stores |
GET | Nearby restaurants list filtered by user coordinates & radius |
{baseUrl}products |
GET | Food catalogue items, categories, add-ons, and pricing |
{baseUrl}cart |
GET / POST | Customer shopping cart synchronization |
{baseUrl}checkout |
POST | Order placement and initialization of online payment gateway |
{baseUrl}my-orders |
GET | Order history and live delivery tracking status |
Local Development & Emulator Setup#
If you are running the Laravel backend locally on your computer via php artisan serve:
| Development Environment | Loopback IP to Localhost | Example baseUrl |
|---|---|---|
| Android Emulator | 10.0.2.2:8000 |
http://10.0.2.2:8000/api/ |
| iOS Simulator (Mac) | localhost:8000 |
http://localhost:8000/api/ |
| Physical Phone on Local Wi-Fi | Your PC's Local Network IP | http://192.168.1.150:8000/api/ |
| Ngrok Tunnel (Recommended) | Public HTTPS Forwarder | https://your-tunnel.ngrok-free.dev/api/ |
When testing on physical Android or iPhone devices during development, using ngrok http 8000 gives you a real HTTPS URL with zero Wi-Fi firewall issues!
API Troubleshooting Checklist#
| Symptom / Error | Root Cause | Resolution |
|---|---|---|
DioException: Connection refused |
Mobile app cannot establish socket to backend IP | Ensure web server is running and firewall allows port 80/443. For emulator, use 10.0.2.2 instead of 127.0.0.1. |
HandshakeException: Certificate verify failed |
Expired or untrusted self-signed SSL certificate | Install a free Let's Encrypt certificate in cPanel / Plesk. Do not use self-signed certificates in production. |
| Images showing broken placeholder icons | baseUrl1 does not point to /storage/ or symlink missing |
Run php artisan storage:link on your Laravel server and verify that https://yourdomain.com/storage/ serves files. |
| HTTP 500 Server Error on API requests | Missing APP_KEY or database credentials error |
Run php artisan key:generate and verify DB_DATABASE in .env. Check storage/logs/laravel.log for exact stack trace. |