Kulcare Docs
DeveloperPatient

Environment Setup Guide

This document explains how to configure environment variables for the Kulcare Patient App.

Environment Files

.env

Contains environment-specific configuration. Never commit this file - it's included in .gitignore.

.env.example

Template file showing all available environment variables with descriptions. This file is committed to the repository.

Getting Started

  1. Copy the example file:

    cp .env.example .env
  2. Fill in the actual values for your environment:

    # Edit .env with your actual values
    nano .env

Environment Variables

API Configuration

VariableRequiredDescriptionExample
VITE_SERVER_URL✅Main server URLhttps://api-stg.kulcare.com
VITE_API_BASE_URL✅API base URLhttps://api-stg.kulcare.com
VITE_ES_SERVER_URL❌Elasticsearch server URLhttps://search.kulcare.com
VITE_CLINIC_DOCTORS_INDEX❌ES doctors index nameclinic_doctors
VITE_ES_SURGERIES_INDEX❌ES surgeries index namesurgeries

Third-party Services

VariableRequiredDescriptionExample
VITE_OPENTOK_SDK_LINK❌OpenTok/Vonage Video SDK URLhttps://static.opentok.com/...
VITE_RAZORPAY_KEY❌Razorpay payment gateway keyrzp_test_...
VITE_MIXPANEL_TOKEN❌Mixpanel analytics tokenabc123...
VITE_GA_ID❌Google Analytics IDG-XXXXXXXXXX
VITE_PUSHER_CHANNEL❌Pusher real-time channelkulcare-channel
VITE_SENTRY_DSN❌Sentry error tracking DSNhttps://...@sentry.io/...

Security & Encryption

VariableRequiredDescriptionExample
VITE_URL_ENCODE_KEY❌Hashids encryption keyyour-secret-key
VITE_BASIC_AUTH_USERNAME❌Basic auth usernamekulcare_user
VITE_BASIC_AUTH_PASSWORD❌Basic auth passwordsecure_password

Environment & Release

VariableRequiredDescriptionExample
VITE_ENVIRONMENT✅Environment typedevelopment, staging, production
VITE_LATEST_RELEASE❌Version tracking1.0.0
VITE_DEBUG❌Enable debug loggingtrue, false

Environment-Specific Configuration

Development

VITE_API_BASE_URL=https://api-stg.kulcare.com
VITE_ENVIRONMENT=development
VITE_DEBUG=true

Staging

VITE_API_BASE_URL=https://api-stg.kulcare.com
VITE_ENVIRONMENT=staging
VITE_DEBUG=false

Production

VITE_API_BASE_URL=https://api.kulcare.com
VITE_ENVIRONMENT=production
VITE_DEBUG=false

API Proxy Configuration

In development, the app uses a Vite proxy to avoid CORS issues:

// vite.config.ts
server: {
  proxy: {
    '/api': {
      target: process.env.VITE_API_BASE_URL || 'https://api-stg.kulcare.com',
      changeOrigin: true,
      rewrite: (path) => path.replace(/^\/api/, ''),
      secure: true,
    },
  },
}

This means:

  • Development: API calls go to /api/* → proxied to the actual API server
  • Production: API calls go directly to VITE_API_BASE_URL

Type-Safe Environment Access

Use the env utility for type-safe environment variable access:

import { env } from '@/lib/env';

// Type-safe access
const apiUrl = env.API_BASE_URL;
const isDebug = env.DEBUG;
const environment = env.ENVIRONMENT; // 'development' | 'staging' | 'production'

Validation

Environment variables are automatically validated on app startup in development mode. Missing required variables will throw an error.

Security Best Practices

  1. Never commit .env files with real credentials
  2. Use different keys for each environment
  3. Rotate secrets regularly
  4. Limit access to production environment variables
  5. Use secure key management for production (e.g., AWS Secrets Manager)

Troubleshooting

API Connection Issues

  1. Check the browser console for configuration logs (development mode only)
  2. Verify the API URL is accessible
  3. Check if CORS is properly configured on the backend
  4. Ensure the Vite proxy is working correctly

Missing Environment Variables

If you see errors about missing environment variables:

  1. Check that .env file exists
  2. Verify variable names use the VITE_ prefix
  3. Ensure no spaces around the = sign in .env
  4. Restart the development server after changing .env

Environment Not Loading

If environment variables aren't being picked up:

  1. Restart the development server
  2. Check the .env file is in the correct location (project root)
  3. Verify variable names are exactly as documented
  4. Check for any syntax errors in the .env file

On this page