Fix Netlify runtime env resolution and Vercel Analytics loading#431
Fix Netlify runtime env resolution and Vercel Analytics loading#431liudmylasovetovs merged 1 commit intodevelopfrom
Conversation
… on Netlify - update server env resolver to read Netlify runtime env safely (supports both globalThis.Netlify and global Netlify identifier) - keep process.env as primary source, Netlify env as fallback - render @vercel/analytics only on Vercel (VERCEL=1) to avoid Netlify 404s
|
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)
📝 WalkthroughWalkthroughThis PR updates the Analytics component rendering condition from checking production environment to checking for Vercel deployment, and refactors Netlify runtime environment access with a new helper function for improved compatibility. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 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
On Netlify SSR/runtime, environment variables were intermittently unavailable in
process.env.Also, Vercel Analytics script was loaded on Netlify and produced 404 errors (
/_vercel/insights/script.js).Changes
frontend/lib/env/server-env.ts:process.envas primary sourceglobalThis.NetlifyNetlifyidentifier (Netlify.env.get)frontend/app/layout.tsx:NODE_ENV === 'production'process.env.VERCEL === '1'(load only on Vercel)Why
Verification
/_vercel/insights/script.js404 in browser console.Risk
Low. Changes are isolated to env resolution and analytics rendering condition.
Summary by CodeRabbit