Skip to content

Commit 306f6ed

Browse files
authored
Merge pull request #10 from paccloud/fix/docs-env-vars
docs: add Vite Gemini + OCR env vars
2 parents 5ef4276 + c866156 commit 306f6ed

3 files changed

Lines changed: 22 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: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,28 @@ 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 (exposed to the browser)** (e.g. `AIza...`)
38+
- `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`)
3739

3840
### Backend (Vercel Functions) - Server-side only
41+
3942
These are only accessible on the server:
43+
4044
- `STACK_PROJECT_ID` - Stack Auth project ID (server-side)
4145
- `STACK_SECRET_SERVER_KEY` - Stack Auth secret key (**NEVER expose to client**)
42-
- `JWT_SECRET` - Secret for signing JWT tokens
46+
- `JWT_SECRET` - Secret for signing JWT tokens (required; API/server will fail fast if missing)
47+
- `JWT_EXPIRES_IN_SECONDS` - Optional; JWT lifetime in seconds (default 86400 / 24h)
4348
- `DATABASE_URL` - PostgreSQL connection string
4449
- All `POSTGRES_*` and `PG*` variables from Neon
50+
- `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.
51+
52+
Mitigations / security guidance:
53+
54+
- **Client-side keys are not secrets**: anything prefixed with `VITE_` is shipped to browsers. Treat `VITE_GEMINI_API_KEY` as public.
55+
- **Prefer server-side proxying** for privileged features: use `GEMINI_API_KEY` only in server routes/functions and enforce auth/authorization there.
56+
- **Rate-limit Gemini-backed endpoints** to reduce abuse and cost exposure.
57+
- **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.
58+
- **Scope and rotate keys**: use least-privilege API restrictions and rotate keys if exposure is suspected.
4559

4660
## Common Issues
4761

@@ -76,6 +90,8 @@ If you get 401 Unauthorized errors when logged in with OAuth:
7690

7791
3. Never commit `.env`, `.env.development`, or `.env.production` files - they're gitignored for security.
7892

93+
4. For the local Express server (`server/server.js`), create `server/.env` (or `.env.local`) with `JWT_SECRET` and `ALLOWED_ORIGINS` that match your dev URLs. See `server/.env.example` for defaults.
94+
7995
## Production Deployment
8096

8197
Environment variables for production are managed in Vercel:

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)