Skip to content

fix(netlify-deploy): expose the build env vars to Next.js sites - #88

Merged
browniebroke merged 1 commit into
mainfrom
fix/next-public-env-vars
Sep 13, 2026
Merged

browniebroke merged 1 commit into
mainfrom
fix/next-public-env-vars

Conversation

@browniebroke

Copy link
Copy Markdown
Owner

Why

The workflow passes PRODUCTION_DEPLOY and REVIEW_ID to the build script.
Those names date back to Gatsby, which reads plain environment variables at build
time. Next.js only inlines variables prefixed with NEXT_PUBLIC_, so a site
migrated from Gatsby to Next.js reads undefined and silently falls back.

That is the case on lescapsules-web,
where lib/metadata.ts reads NEXT_PUBLIC_REVIEW_ID and
NEXT_PUBLIC_PRODUCTION_DEPLOY: deploy previews advertise
https://www.lescapsules.com as their siteUrl, which then feeds metadataBase,
the sitemap and the manifest, so a preview points search engines and social cards
at production.

What

Passes both variables under their prefixed name as well, and documents the ones
the build script gets. Plain names are kept so that Gatsby sites using the
workflow are unaffected.

Consumers pick the fix up when their pinned ref moves to the next release.

🤖 Generated with Claude Code

Next.js only inlines variables prefixed with NEXT_PUBLIC_, so sites
migrated from Gatsby were silently getting undefined.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@browniebroke
browniebroke merged commit 8f15f82 into main Sep 13, 2026
1 check passed
@browniebroke
browniebroke deleted the fix/next-public-env-vars branch September 13, 2026 10:20
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.

1 participant