Conventions
- Each part ships two templates,
env/env.devandenv/env.prod; a script copies the chosen one to.env:npm run switch_to_dev/switch_to_prod..envis gitignored. VITE_*(app, admin) andPUBLIC_*(website) are inlined into the built bundle — so switch to prod before building, and never put a secret in one (it ships to every visitor). They’re for public values: URLs, public keys, feature flags.- Real secrets live only in the API’s server environment (
env.prodon the server) — filled into theREPLACE_ME_*placeholders, never committed. A placeholder left unfilled there counts as unset (that integration stays off); production refuses to start withoutDATABASE_URL,REDIS_URL,JWT_SECRETandDATA_ENCRYPTION_KEY(see Deployment). - A placeholder left unfilled in the app’s
env.prodis caught: an optional integration whose value still starts withREPLACE_MEcounts as unset and stays off, andnpm run buildstops ifVITE_BACKEND_URLis still one (see App).
Where each part’s variables live
The minimum to boot the backend
DATABASE_URL, REDIS_URL, JWT_SECRET (≥32 chars). Everything else (Google/Apple, SMTP,
RevenueCat, OneSignal, admin) is optional and inert until configured — an unconfigured
integration returns a clear error rather than crashing at boot.
Cross-part wiring that must agree
- App → API base:
VITE_BACKEND_URL— the API origin. - Website support form → API:
PUBLIC_SUPPORT_ENDPOINTis the full URL of the API’sPOST /v1/support— e.g.https://api.example.com/v1/support. Empty = the form runs in demo mode (validates, then shows an “email us” notice). - Support form → your inbox: the API emails each form message to its
MAIL_REPLY_TOwith Reply-To set to the sender, so SMTP must be configured on the API. Nothing is stored — the in-app ticket inbox is for signed-in accounts only. - Admin origin ↔ API CORS: set
ADMIN_URLin the API env to the admin’s origin, or CORS refuses it (looks like an auth bug). Native schemes are always allowed. CORS_ORIGINS(API) must list each web origin (app web build, website) exactly.client_id: the app’sVITE_CLIENT_IDmust be listed in the API’sCLIENT_IDS(the kit ships both asshipwide), or sign-in fails withunknown_client. Rename them together. The admin’sadminis always allowed.
Gotchas
VITE_APP_NAMEnamespaces all local data on the app (encrypted storage, settings, cache, deep-link scheme). Changing it after launch orphans users’ existing local data.- Add any new
VITE_*tosrc/vite-env.d.ts—vite/client’s index signature means a typo is not a type error, it just readsundefined.