Skip to content

Commit 280ba23

Browse files
author
Your Name
committed
πŸ”’ Fix Netlify Secrets Scanning Issue
βœ… NETLIFY BUILD FIX: - Added SECRETS_SCAN_OMIT_KEYS to exclude Next.js public env vars - Configured Netlify to allow Firebase and EmailJS public variables - Added comprehensive documentation for secrets scanning πŸ”§ CONFIGURATION UPDATES: - Updated netlify.toml with proper secrets scanning exclusions - Added explanatory comments for public environment variables - Created NETLIFY_SECRETS_SCANNING.md documentation πŸ“š SECURITY CLARIFICATION: - NEXT_PUBLIC_* variables are intentionally public (client-side) - Firebase security handled by Firestore rules, not API key secrecy - EmailJS security handled by domain restrictions and rate limiting 🎯 BUILD STATUS: - Build completed successfully (all AI models working) - Startup validations passed (all 8 models configured) - Only secrets scanning was blocking deployment This should resolve the Netlify deployment failure and allow successful build completion.
1 parent 5e89faa commit 280ba23

2 files changed

Lines changed: 66 additions & 0 deletions

File tree

β€ŽNETLIFY_SECRETS_SCANNING.mdβ€Ž

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Netlify Secrets Scanning Configuration
2+
3+
## Issue
4+
Netlify's secrets scanning feature flags `NEXT_PUBLIC_*` environment variables as potential secrets, causing build failures.
5+
6+
## Why This Happens
7+
- Netlify scans build output for potential secrets
8+
- Next.js `NEXT_PUBLIC_*` variables are intentionally embedded in client-side code
9+
- These variables appear in webpack bundles, triggering the scanner
10+
11+
## Solution
12+
Configure `SECRETS_SCAN_OMIT_KEYS` in `netlify.toml` to exclude these public variables:
13+
14+
```toml
15+
[build.environment]
16+
SECRETS_SCAN_OMIT_KEYS = "NEXT_PUBLIC_FIREBASE_API_KEY,NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN,..."
17+
```
18+
19+
## Safe to Expose
20+
These variables are **intentionally public** and safe to expose:
21+
22+
### Firebase Configuration (Public)
23+
- `NEXT_PUBLIC_FIREBASE_API_KEY` - Firebase Web API key (public)
24+
- `NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN` - Firebase auth domain (public)
25+
- `NEXT_PUBLIC_FIREBASE_PROJECT_ID` - Firebase project ID (public)
26+
- `NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET` - Firebase storage bucket (public)
27+
- `NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID` - Firebase messaging ID (public)
28+
- `NEXT_PUBLIC_FIREBASE_APP_ID` - Firebase app ID (public)
29+
- `NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID` - Google Analytics ID (public)
30+
31+
### EmailJS Configuration (Public)
32+
- `NEXT_PUBLIC_EMAILJS_SERVICE_ID` - EmailJS service ID (public)
33+
- `NEXT_PUBLIC_EMAILJS_TEMPLATE_ID` - EmailJS template ID (public)
34+
- `NEXT_PUBLIC_EMAILJS_USER_ID` - EmailJS user ID (public)
35+
- `NEXT_PUBLIC_EMAILJS_WELCOME_TEMPLATE_ID` - EmailJS template ID (public)
36+
37+
## Security Note
38+
- These are **client-side** configuration values
39+
- They are **meant to be public** and visible in browser dev tools
40+
- Firebase security is handled by Firestore rules, not API key secrecy
41+
- EmailJS security is handled by domain restrictions and rate limiting
42+
43+
## Alternative Solutions
44+
If you prefer not to modify the config, you can also:
45+
46+
1. **Disable secrets scanning entirely:**
47+
```toml
48+
[build.environment]
49+
SECRETS_SCAN_ENABLED = "false"
50+
```
51+
52+
2. **Use path exclusions:**
53+
```toml
54+
[build.environment]
55+
SECRETS_SCAN_OMIT_PATHS = ".next/cache/**,.next/static/**"
56+
```
57+
58+
## References
59+
- [Netlify Secrets Scanning Docs](https://docs.netlify.com/security/secrets-scanning/)
60+
- [Next.js Environment Variables](https://nextjs.org/docs/basic-features/environment-variables)
61+
- [Firebase Web API Keys](https://firebase.google.com/docs/projects/api-keys)

β€Žnetlify.tomlβ€Ž

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# Netlify Configuration for CODEEX AI
22
# Production-ready settings for Next.js PWA deployment
33

4+
# Note: NEXT_PUBLIC_* variables are intentionally public and safe to expose in client-side code
5+
# They are required for Firebase and EmailJS client-side functionality
6+
47
[build]
58
command = "npm run build:netlify"
69
publish = ".next"
@@ -15,6 +18,8 @@
1518
NPM_FLAGS = "--legacy-peer-deps"
1619
NEXT_TELEMETRY_DISABLED = "1"
1720
SKIP_ENV_VALIDATION = "true"
21+
# Disable secrets scanning for Next.js public env vars
22+
SECRETS_SCAN_OMIT_KEYS = "NEXT_PUBLIC_FIREBASE_API_KEY,NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN,NEXT_PUBLIC_FIREBASE_PROJECT_ID,NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET,NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID,NEXT_PUBLIC_FIREBASE_APP_ID,NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID,NEXT_PUBLIC_EMAILJS_SERVICE_ID,NEXT_PUBLIC_EMAILJS_TEMPLATE_ID,NEXT_PUBLIC_EMAILJS_USER_ID,NEXT_PUBLIC_EMAILJS_WELCOME_TEMPLATE_ID"
1823

1924
# Headers for PWA and security
2025
[[headers]]

0 commit comments

Comments
Β (0)