You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/ENVIRONMENT_VARIABLES.md
+10-1Lines changed: 10 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -34,12 +34,13 @@ These are bundled into the client code and exposed to the browser:
34
34
-`VITE_STACK_PROJECT_ID` - Stack Auth project ID
35
35
-`VITE_STACK_PUBLISHABLE_CLIENT_KEY` - Stack Auth public key
36
36
-`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...`)
38
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`)
39
39
40
40
### Backend (Vercel Functions) - Server-side only
41
41
42
42
These are only accessible on the server:
43
+
43
44
-`STACK_PROJECT_ID` - Stack Auth project ID (server-side)
44
45
-`STACK_SECRET_SERVER_KEY` - Stack Auth secret key (**NEVER expose to client**)
45
46
-`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:
50
51
- All `POSTGRES_*` and `PG*` variables from Neon
51
52
-`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.
52
53
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.
0 commit comments