Skip to content

(SP: 1) [FIX] Add netlify-plugin-bundle-env for Netlify SSR env var delivery#427

Merged
ViktorSvertoka merged 9 commits intodevelopfrom
sl/feat/db-optimization
Mar 28, 2026
Merged

(SP: 1) [FIX] Add netlify-plugin-bundle-env for Netlify SSR env var delivery#427
ViktorSvertoka merged 9 commits intodevelopfrom
sl/feat/db-optimization

Conversation

@LesiaUKR
Copy link
Copy Markdown
Collaborator

@LesiaUKR LesiaUKR commented Mar 28, 2026

Goal

Fix all SSR page crashes on Netlify develop deploy caused by environment variables not reaching serverless function runtime.

Scope

  • Add netlify-plugin-bundle-env plugin to netlify.toml — embeds env vars into serverless functions during build, as recommended by Netlify docs
  • Remove unsafe env block from next.config.ts that inlined server secrets into client-side bundles
  • Keep diagnostic runtime env log in db/index.ts until fix is confirmed

Context

Netlify does not deliver dashboard env vars to Next.js SSR runtime — this is a known platform limitation (opennextjs/opennextjs-netlify#2754). The official workaround is netlify-plugin-bundle-env, which injects env vars into function bundles at build time.

Expected impact

All 28 SSR pages (blog, quizzes, leaderboard, dashboard, shop, auth, admin) should work on Netlify develop deploy.

Out of scope

  • Blog categories hardcode in header — separate follow-up after SSR stability confirmed
  • Removing diagnostic log from db/index.ts — after env vars confirmed in runtime logs

Summary by CodeRabbit

  • Chores
    • Optimized concurrent data fetching for improved performance.
    • Updated environment configuration handling.
    • Enhanced deployment infrastructure setup.

@vercel
Copy link
Copy Markdown
Contributor

vercel bot commented Mar 28, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
devlovers-net Ignored Ignored Preview Mar 28, 2026 3:46pm

Request Review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 28, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 8a0e6cc3-e91a-48eb-9603-bf056d67bffc

📥 Commits

Reviewing files that changed from the base of the PR and between b969fbf and 7b9212b.

📒 Files selected for processing (3)
  • frontend/app/[locale]/layout.tsx
  • frontend/next.config.ts
  • netlify.toml
💤 Files with no reviewable changes (1)
  • frontend/next.config.ts

📝 Walkthrough

Walkthrough

This PR optimizes data fetching in the layout component by concurrently loading messages and blog categories using Promise.all, removes Next.js runtime environment variable exports from configuration, and adds a Netlify environment bundling plugin.

Changes

Cohort / File(s) Summary
Layout Concurrent Fetching
frontend/app/[locale]/layout.tsx
Changed from sequential fetching to concurrent Promise.all for getMessages and getCachedBlogCategories, removing the empty blogCategories array initialization.
Environment Configuration Removal
frontend/next.config.ts
Removed env block that exposed APP_ENV and DATABASE_URL runtime environment variables via Next.js configuration.
Netlify Plugin Addition
netlify.toml
Added new netlify-plugin-bundle-env plugin configuration alongside existing @netlify/plugin-nextjs plugin.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

Suggested labels

bug

Suggested reviewers

  • AM1007
  • ViktorSvertoka
  • liudmylasovetovs

Poem

🐰 With concurrent flows we race and leap,
Blog categories no longer sleep,
Environment secrets tucked away tight,
Netlify bundles them just right! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly references the main change: adding netlify-plugin-bundle-env to fix Netlify SSR environment variable delivery, which aligns with the primary objective and the netlify.toml modification.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch sl/feat/db-optimization

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@ViktorSvertoka ViktorSvertoka merged commit 7750e08 into develop Mar 28, 2026
8 checks passed
@ViktorSvertoka ViktorSvertoka deleted the sl/feat/db-optimization branch March 28, 2026 15:08
@LesiaUKR LesiaUKR restored the sl/feat/db-optimization branch March 28, 2026 15:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants