Skip to content

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.com

Replace 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.com

Subdomain Setup

env
APP_API_URL=https://shop.mycompany.com/api/v1
APP_SITE_URL=https://shop.mycompany.com

Demo/Staging

env
APP_API_URL=https://staging.mystore.com/api/v1
APP_SITE_URL=https://staging.mystore.com

Local 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:8000

Finding Your API URL

  1. Go to your Botble admin panel
  2. Navigate to Settings → General
  3. Find the Site URL
  4. Append /api/v1 to 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/products

Using 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:

  1. Stop the current server (Ctrl+C)
  2. 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     # Production

Load specific environment:

bash
# Development
APP_API_URL=http://localhost:8000/api/v1 npm start

# Production
APP_API_URL=https://mystore.com/api/v1 npm start

Troubleshooting

"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?