Configuring API Base URL
Overview
The API base URL connects your mobile app to your Botble e-commerce backend. This is the most important configuration setting.
Configuration
Step 1: Update API URL
Open .env file and update:
env
APP_API_URL=https://your-website.com/api/v1
APP_SITE_URL=https://your-website.comReplace your-website.com with your actual Botble website domain.
Examples
Production Website
env
APP_API_URL=https://mystore.com/api/v1
APP_SITE_URL=https://mystore.comSubdomain Setup
env
APP_API_URL=https://shop.mycompany.com/api/v1
APP_SITE_URL=https://shop.mycompany.comDemo/Staging
env
APP_API_URL=https://staging.mystore.com/api/v1
APP_SITE_URL=https://staging.mystore.comLocal Development
env
# For iOS Simulator
APP_API_URL=http://localhost:8000/api/v1
APP_SITE_URL=http://localhost:8000
# For Android Emulator (use your computer's IP)
APP_API_URL=http://10.0.2.2:8000/api/v1
APP_SITE_URL=http://10.0.2.2:8000
# For physical device (use your computer's local IP)
APP_API_URL=http://192.168.1.100:8000/api/v1
APP_SITE_URL=http://192.168.1.100:8000Finding Your API URL
- Go to your Botble admin panel
- Navigate to Settings → General
- Find the Site URL
- Append
/api/v1to it
Example:
- Site URL:
https://mystore.com - API URL:
https://mystore.com/api/v1
Testing the Connection
Using curl
bash
curl https://your-website.com/api/v1/ecommerce/productsUsing browser
Visit: https://your-website.com/api/v1/ecommerce/products
You should see JSON data with products.
Important Notes
HTTPS Required
- Always use
https://for production http://only for local development- SSL certificate must be valid
URL Format
- Do NOT include trailing slash:
https://mystore.com/api/v1 - NOT:
https://mystore.com/api/v1/
CORS Configuration
Ensure your backend allows mobile app requests. Contact your backend developer if you get CORS errors.
Applying Changes
After modifying .env:
- Stop the current server (Ctrl+C)
- Restart with clear cache:bash
npm start -- --clear
Note: Hot reload does NOT apply .env changes. You must restart the server.
Multiple Environments
Create separate environment files:
.env.development # Local development
.env.staging # Staging server
.env.production # ProductionLoad specific environment:
bash
# Development
APP_API_URL=http://localhost:8000/api/v1 npm start
# Production
APP_API_URL=https://mystore.com/api/v1 npm startTroubleshooting
"Network Error"
- Check URL is correct
- Verify website is online
- Test in browser first
"401 Unauthorized"
- API might require authentication
- Check if API access is enabled on backend
"CORS Error"
- Backend needs to allow app requests
- Contact backend developer
"SSL Certificate Error"
- Ensure valid SSL certificate
- Don't use self-signed certs in production
Need Help?
- Check the API Integration Guide
- Read the Troubleshooting Guide
- Contact support for assistance
