CROP
ProjectsAdmin Panel

Vercel Environment Variables Setup

Health Analytics API Integration

Vercel Environment Variables Setup

Health Analytics API Integration

Required Environment Variables for Vercel

Add the following environment variable to your Vercel project:

Production Environment

# Health Analytics API (GCP Cloud Run)
HEALTH_ANALYTICS_API_URL=https://health-analytics-service-222426967009.us-east1.run.app

How to Add in Vercel Dashboard

  1. Go to https://vercel.com/your-project/settings/environment-variables
  2. Click "Add New" button
  3. Enter:
    • Key: HEALTH_ANALYTICS_API_URL
    • Value: https://health-analytics-service-222426967009.us-east1.run.app
    • Environment: Select "Production", "Preview", and "Development"
  4. Click "Save"
  5. Redeploy your application for changes to take effect

Verification

After deployment, verify the variable is loaded:

# Check Vercel logs during deployment
vercel logs --follow

# Or test the API endpoint directly
curl https://your-app.vercel.app/api/health/analytics

Expected response:

{
  "status": "healthy",
  "service": "health-analytics",
  "mongodb": "connected",
  "timestamp": "2025-11-17T..."
}

Existing Environment Variables

Ensure these variables are also set in Vercel:

# MongoDB
MONGODB_URI=mongodb+srv://...
MONGODB_DB_NAME=crop_prod

# Clerk Authentication
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=pk_...
CLERK_SECRET_KEY=sk_...

# Search Service (via API Gateway - recommended)
SEARCH_SERVICE_URL=https://crop-gateway-2u6j9u5d.ue.gateway.dev
# Direct Cloud Run URL (for debugging only):
# SEARCH_SERVICE_URL=https://search-service-222426967009.us-east1.run.app

# DIS (Dealer Information System) - Clinton Tractor Inventory
# Optional - enables real-time dealer inventory widget on dashboard
DIS_API_KEY=your-dis-api-key
# DIS_API_URL=https://cl2342.disprism.com  # default, no need to set
# DIS_DEALER_ID=C                           # default, no need to set

Local Development

For local development, the variable is already added to .env.local:

HEALTH_ANALYTICS_API_URL=https://health-analytics-service-222426967009.us-east1.run.app

No additional setup needed for local development.

Troubleshooting

If API calls fail after deployment:

  1. Check Vercel environment variables are set correctly
  2. Verify API URL is accessible: curl https://health-analytics-service-222426967009.us-east1.run.app/health
  3. Check Vercel function logs for errors
  4. Ensure CORS is enabled on the Health Analytics service (already configured)

If you see "Unable to Load Data" error:

  1. Check browser network tab for failed requests
  2. Verify the API route is proxying correctly: /api/health/analytics/coverage
  3. Check Vercel function logs for error details
  4. Ensure MongoDB connection is working

On this page