Configuration & Deployment
This page explains how to configure and deploy the CryptoLens frontend and backend.
🔑 Environment Variables
Both the mobile application and the Cloudflare Worker rely on environment variables to communicate securely and fetch data.
Frontend App (.env)
Create a .env file in the root of the project:
# The URL of your deployed or local Cloudflare Worker backend
EXPO_PUBLIC_API_URL=https://your-worker.your-subdomain.workers.dev
# Secret key matching the worker's APP_SECRET to secure requests
EXPO_PUBLIC_APP_SECRET=your_super_secret_tokenBackend Worker Secrets (.dev.vars / Wrangler Secrets)
For local development, create worker/.dev.vars:
APP_SECRET=your_super_secret_token
CG_KEY=your_coingecko_api_key
# Additional keys as required by worker integrations⚡ Backend Worker Deployment
The backend worker acts as a proxy cache and is designed to deploy seamlessly to Cloudflare Workers.
1. Login to Cloudflare CLI
Authenticate Wrangler with your Cloudflare account:
cd worker
bunx wrangler login2. Configure wrangler.toml
Verify the wrangler.toml configuration matches your preferences (e.g., compatibility dates, name, KV namespace bindings).
3. Set Production Secrets
Upload your secret tokens securely to Cloudflare:
bunx wrangler secret put APP_SECRET
# Enter your super secret token when prompted
bunx wrangler secret put CG_KEY
# Enter your CoinGecko API key4. Deploy the Worker
Run the deployment command:
bunx wrangler deployOnce deployment is complete, Wrangler will output your production Worker URL (e.g., https://cryptolens-worker.username.workers.dev). Update your frontend .env file with this URL.
🛡 Security Best Practices
- Never Commit Secrets: Ensure
.envandworker/.dev.varsare added to your.gitignorefile. - Rotate keys: Rotate your
APP_SECRETregularly. If the secret is leaked, anyone can query your proxy, leading to potential exhaustion of your CoinGecko/CoinMarketCap API limits. - IP Binding: When developing locally, only bind Wrangler to
0.0.0.0inside safe private local networks.