SansiStore uses a singleDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/ProcesosAgilesUMSS/sansistore/llms.txt
Use this file to discover all available pages before exploring further.
.env file at the repository root to drive both local-emulator and live-production modes. The key that controls which mode is active is PUBLIC_APP_ENV. Setting it to development (the default in .env.example) makes every Firebase SDK call route to local emulators; setting it to production points the app at the real Firebase project.
Environment Summary
| Mode | PUBLIC_APP_ENV | Firebase target | Admin credentials needed? |
|---|---|---|---|
| Local development | development | Emulators (localhost) | No — emulators accept any token |
| Production / Vercel | production | Live Firebase project | Yes — service account required |
All Variables
Client-side Firebase Config (PUBLIC_*)
Client-side Firebase Config (PUBLIC_*)
These variables are prefixed with
PUBLIC_ and are bundled into the client JavaScript. They are safe to expose in the browser — Firebase projects are identified by these values, not secured by them.| Variable | Example value | Description |
|---|---|---|
PUBLIC_FIREBASE_API_KEY | AIzaSy... | Firebase Web API key. In development mode the value is overridden to dummy-api-key-for-emulator at runtime. |
PUBLIC_FIREBASE_AUTH_DOMAIN | sansistore.firebaseapp.com | OAuth redirect domain for Firebase Auth. |
PUBLIC_FIREBASE_PROJECT_ID | sansistore | Firestore project identifier. Also used by the Admin SDK. |
PUBLIC_FIREBASE_STORAGE_BUCKET | sansistore.appspot.com | Cloud Storage bucket for product images. |
PUBLIC_FIREBASE_MESSAGING_SENDER_ID | 000000000000 | Sender ID for Firebase Cloud Messaging (future push notifications). |
PUBLIC_FIREBASE_APP_ID | 1:000:web:abc | Firebase App ID. |
PUBLIC_FIREBASE_MEASUREMENT_ID | G-XXXXXXX | Google Analytics measurement ID. Analytics is only initialised when PUBLIC_APP_ENV=production. |
PUBLIC_APP_ENV | development | production | The main environment switch. Any value other than production activates emulator mode. |
Server-side Firebase Admin Credentials
Server-side Firebase Admin Credentials
These variables are never sent to the browser. They are used exclusively inside Astro server routes and API endpoints via the
firebase-admin SDK (src/lib/firebase-admin.ts).You can supply credentials in one of two ways — the Admin SDK checks them in this order:- Full service account JSON string — paste the entire JSON as one line:
- Individual fields — split the service account into three separate variables:
Note: Vercel stores the private key with literal
\nescape sequences. Thefirebase-admin.tsfile automatically converts them with.replace(/\\n/g, '\n').
PUBLIC_APP_ENV !== 'production', the Admin SDK runs without credentials against the local emulators. In production on Vercel, one of the two options above must be configured.| Variable | Description |
|---|---|
FIREBASE_SERVICE_ACCOUNT_KEY | Full service account JSON as a single-line string. Takes precedence over the individual fields below. |
FIREBASE_CLIENT_EMAIL | client_email field from the service account JSON. Used when FIREBASE_SERVICE_ACCOUNT_KEY is not set. |
FIREBASE_PRIVATE_KEY | private_key field from the service account JSON. Literal \n sequences are replaced at runtime. |
Dev-only Bypass Flags
Dev-only Bypass Flags
These flags exist only for local development convenience and must never reach production.
| Variable | Default | Description |
|---|---|---|
ENABLE_DEV_ADMIN_BYPASS | true (in .env.example) | When true, grants admin-level access to the UID specified by DEV_ADMIN_UID without requiring a real role in Firestore. Use this only while auth/role user stories are not yet fully implemented. |
DEV_ADMIN_UID | dev-admin | The Firebase Auth UID that receives the bypass admin grant when ENABLE_DEV_ADMIN_BYPASS=true. |
How the SDK Switches Between Emulators and Production
The client-sidesrc/lib/firebase.ts reads PUBLIC_APP_ENV at module initialisation time and conditionally connects to the emulators:
src/lib/firebase-admin.ts does the same via environment variables that the Firebase Admin SDK reads natively:
experimentalForceLongPolling: true flag on the client Firestore instance avoids WebSocket connection failures inside some environments (Docker, certain corporate proxies) while using the emulator.
Setting Variables on Vercel
Production secrets are stored in Vercel project settings → Environment Variables, not in the repository. To update them:- Go to the Vercel dashboard → your SansiStore project → Settings → Environment Variables.
- Add or update the variable for the target environment (
Production,Preview, orDevelopment). - Redeploy to apply the changes.