fix(netlify-env): stabilize auth/csrf secrets in SSR runtime via readServerEnv#432
Conversation
Switch server secret reads from process.env to readServerEnv() in auth and CSRF modules. This adds Netlify runtime fallback (Netlify.env.get) and prevents 5xx/502 when process.env is empty. Fail-closed behavior is preserved if secrets are truly missing.
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughTwo authentication secret retrieval methods were refactored to use a centralized Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~5 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Problem
developon Netlify could return 5xx/502 because some server env vars are not always available throughprocess.envat runtime.Root cause
Approach #8 (
readServerEnv+ Netlify fallback) was applied only partially:AUTH_SECRETinlib/auth.tsstill used directprocess.envCSRF_SECRETinlib/security/csrf.tsstill used directprocess.envChanges
frontend/lib/auth.ts:AUTH_SECRETviareadServerEnv('AUTH_SECRET')frontend/lib/security/csrf.ts:CSRF_SECRETviareadServerEnv('CSRF_SECRET')Why this is safe
throwwhen secret is truly missing).Verification checklist
/enon Netlify develop (no 502)/api/auth/me(no 5xx)Summary by CodeRabbit