Skip to main content

Frontend Environment Variables

RoundTripWeb uses Vite environment variables that are baked into the build at compile time — they are not runtime variables. This has important implications for how they are managed and updated.


Source of Truth — ADO Pipeline Variables

danger

Critical The ADO pipeline variables are the only source of truth for production and dev builds. The following are all ignored during CI builds:

  • Local .env.production file
  • Cloudflare Pages dashboard environment variables
  • Any other .env.* file on the agent machine

If you update a Vite env var anywhere other than the ADO pipeline variables, it will have no effect on the deployed build.

The build step in azure-pipelines.yml explicitly passes ADO variables into the Vite build:

- script: npm run build
displayName: 'Build'
env:
VITE_API_BASE_URL: $(VITE_API_BASE_URL)
VITE_ENTRA_CLIENT_ID: $(VITE_ENTRA_CLIENT_ID)
VITE_ENTRA_AUTHORITY: $(VITE_ENTRA_AUTHORITY)
VITE_ENTRA_KNOWN_AUTHORITY: $(VITE_ENTRA_KNOWN_AUTHORITY)
VITE_ENTRA_REDIRECT_URI: $(VITE_ENTRA_REDIRECT_URI)
VITE_ENTRA_SCOPE: $(VITE_ENTRA_SCOPE)
VITE_VAPID_PUBLIC_KEY: $(VITE_VAPID_PUBLIC_KEY)

These override everything else. This is the only place that matters for deployed builds.


Where Each Variable Lives

VariableWhere to UpdateNotes
VITE_API_BASE_URLADO pipeline variablesAPI base URL
VITE_ENTRA_CLIENT_IDADO pipeline variablesEntra Web Client app registration ID
VITE_ENTRA_AUTHORITYADO pipeline variablesEntra CIAM authority URL
VITE_ENTRA_KNOWN_AUTHORITYADO pipeline variablesEntra known authority hostname
VITE_ENTRA_REDIRECT_URIADO pipeline variablesCritical — must match Entra app registration
VITE_ENTRA_SCOPEADO pipeline variablesAPI scope for token requests
VITE_VAPID_PUBLIC_KEYADO pipeline variablesWeb Push VAPID public key

Production vs Dev Pipeline Variables

Both the production and dev pipelines have their own set of pipeline variables. They must be kept in sync when adding new variables.

PipelineFileVariables location
Productionazure-pipelines.ymlADO → RoundTripWeb pipeline → Variables
Developmentazure-pipelines-dev.ymlADO → RoundTripWeb Dev pipeline → Variables

Local Development

For local development, create a .env.local file (gitignored) with your local values. This file IS used by npm run dev since the pipeline env: block doesn't apply locally.

.env.production is also gitignored and used by npm run build locally — but not by the CI pipeline since the ADO env: block overrides it.


How to Update a Variable

  1. Go to ADO → RoundTripWeb pipeline → Edit → Variables
  2. Find the variable and update the value
  3. Re-run the pipeline — a fresh build will bake in the new value
  4. Verify in Cloudflare Pages → roundtrip project → latest deployment → Environment variables that the new value appears

:::warning Re-run Required Updating the ADO pipeline variable alone is not enough — you must trigger a new pipeline run for the change to take effect. The previous build artifact still has the old value baked in. :::


Cloudflare Pages Dashboard Variables

The Cloudflare Pages dashboard also has environment variable settings but these are not used because our builds come from ADO via Wrangler deploy, not from Cloudflare's own build system. The Cloudflare dashboard variables are effectively decorative in our setup — they show what was used in the last build but updating them there has no effect.

This is a known source of confusion — the Cloudflare dashboard shows the correct values but updating them there does nothing. Always update ADO pipeline variables.