Skip to content

Commit 30fe7ac

Browse files
committed
docs: sync Gemini env vars in examples
1 parent 6816bf7 commit 30fe7ac

3 files changed

Lines changed: 15 additions & 1 deletion

File tree

app/.env.example

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ VITE_API_URL=http://localhost:3000
1212
VITE_STACK_PROJECT_ID=your-project-id
1313
VITE_STACK_PUBLISHABLE_CLIENT_KEY=pck_your-publishable-key
1414

15+
VITE_GEMINI_API_KEY=AIza...
16+
1517
# Backend (server-side only) - NEVER expose these to the client
1618
STACK_PROJECT_ID=your-project-id
1719
STACK_SECRET_SERVER_KEY=ssk_your-secret-key

docs/ENVIRONMENT_VARIABLES.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,13 @@ These are bundled into the client code and exposed to the browser:
3434
- `VITE_STACK_PROJECT_ID` - Stack Auth project ID
3535
- `VITE_STACK_PUBLISHABLE_CLIENT_KEY` - Stack Auth public key
3636
- `VITE_API_URL` - API base URL (empty for production, http://localhost:3000 for dev)
37-
- `VITE_GEMINI_API_KEY` - **Required**; Gemini API key used for Gemini integration and bundled into client code (e.g. `AIza...`)
37+
- `VITE_GEMINI_API_KEY` - **Required**; Gemini API key used for Gemini integration and **bundled into client code (exposed to the browser)** (e.g. `AIza...`)
3838
- `VITE_OCR_ENDPOINT` - **Optional**; custom OCR backend endpoint URL (default: use the app's built-in OCR flow/config if unset; e.g. `http://localhost:3000/api/ocr`)
3939

4040
### Backend (Vercel Functions) - Server-side only
4141

4242
These are only accessible on the server:
43+
4344
- `STACK_PROJECT_ID` - Stack Auth project ID (server-side)
4445
- `STACK_SECRET_SERVER_KEY` - Stack Auth secret key (**NEVER expose to client**)
4546
- `JWT_SECRET` - Secret for signing JWT tokens (required; API/server will fail fast if missing)
@@ -50,6 +51,14 @@ These are only accessible on the server:
5051
- All `POSTGRES_*` and `PG*` variables from Neon
5152
- `GEMINI_API_KEY` - **MUST be server-side only** (no `VITE_` prefix); Gemini API key for AI features (e.g., spreadsheet parsing). **NEVER expose to client code**. All Gemini API calls must be routed through server endpoints (e.g., `/api/parse-spreadsheet`) - the browser should never have direct access to this key.
5253

54+
Mitigations / security guidance:
55+
56+
- **Client-side keys are not secrets**: anything prefixed with `VITE_` is shipped to browsers. Treat `VITE_GEMINI_API_KEY` as public.
57+
- **Prefer server-side proxying** for privileged features: use `GEMINI_API_KEY` only in server routes/functions and enforce auth/authorization there.
58+
- **Rate-limit Gemini-backed endpoints** to reduce abuse and cost exposure.
59+
- **Restrict keys in Google Cloud**: apply API restrictions (enable only the needed APIs), lock down allowed origins/referrers for browser keys (for `VITE_GEMINI_API_KEY`), and restrict server keys by IP/service account where possible.
60+
- **Scope and rotate keys**: use least-privilege API restrictions and rotate keys if exposure is suspected.
61+
5362
## Common Issues
5463

5564
### "Invalid project ID" Error

server/.env.example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,6 @@ UPLOAD_DIR=./uploads
2727

2828
# Bcrypt Configuration
2929
BCRYPT_SALT_ROUNDS=10
30+
31+
# Gemini API Configuration
32+
GEMINI_API_KEY=AIza...

0 commit comments

Comments
 (0)