Skip to main content

Frontend Configuration

The frontend uses Vite's built-in environment variable system for configuration. All environment variables exposed to the frontend must be prefixed with VITE_.

Environment Variables

VariableDescriptionRequired
VITE_API_BASE_URLBackend API base URL. Defaults to /api/v1 when unset.No
VITE_POSTHOG_KEYPostHog project API key. Analytics are disabled entirely when this is absent.No
VITE_POSTHOG_HOSTPostHog host URL (e.g. your self-hosted instance).No
VITE_POSTHOG_ENABLEDExplicit toggle for PostHog analytics.No

See frontend/.env.example for the canonical list with example values.

Environment Files

Local development

Local development needs no environment file. Running npm run dev starts the Vite dev server, which proxies /api to http://localhost:8080 (see vite.config.ts), and VITE_API_BASE_URL defaults to /api/v1 when unset — so requests resolve correctly without any configuration.

If you need to override a default locally, create a .env.local file (git-ignored) using frontend/.env.example as a reference.

.env.production

Used during production builds with npm run build. This file is committed to the repository because it contains only the public API URL, not secrets:

VITE_API_BASE_URL=https://api-console.prxm.uz/api/v1

The value must include the /api/v1 suffix — the API client prepends it directly to every request path, so omitting it points all calls at the wrong URL.

Authentication

The frontend uses JWT-based authentication. Users log in via the /login page, which stores JWT access and refresh tokens in localStorage. The API client (lib/api/client.ts, re-exported from the lib/api/ module) automatically attaches the access token as a Bearer header on every request and handles token refresh transparently.

How Vite Environment Variables Work

Vite replaces import.meta.env.VITE_* references at build time with their actual values. This means:

  • Variables are statically embedded into the built JavaScript bundle
  • Changing a variable requires rebuilding the application
  • Only variables prefixed with VITE_ are exposed to client-side code
  • Variables without the VITE_ prefix remain server-side only and are not included in the bundle