Skip to content

fix(frontend): stop missing NEXT_PUBLIC_CONTRACT_ID from crashing every page - #1581

Merged
mimijuwonlo-commits merged 2 commits into
Split-Naira:mainfrom
Godsmiracle001:fix/env-resilience
Oct 27, 2026
Merged

mimijuwonlo-commits merged 2 commits into
Split-Naira:mainfrom
Godsmiracle001:fix/env-resilience

Conversation

@mimijuwonlo-commits

Copy link
Copy Markdown
Contributor

Problem

Deployments without NEXT_PUBLIC_CONTRACT_ID crash every route in the browser, including the public landing page:

Error: [env] Frontend misconfigured
  ✗  NEXT_PUBLIC_CONTRACT_ID: Invalid input: expected string, received undefined

validateEnv() required the variable whenever NODE_ENV === "production". That check runs when the browser loads the bundle, not only at build time. No frontend code signs against this value; transactions are built by the backend from its own CONTRACT_ID.

Change

  • A missing or empty NEXT_PUBLIC_CONTRACT_ID now logs a warning instead of throwing. A malformed value still throws.
  • Replaced the production-throw test with one asserting the new behaviour, and added tests for the empty and malformed cases.
  • Removed the root optionalDependencies pin on lightningcss-win32-x64-msvc@^1.33.0. It did not match the lightningcss@1.32.0 that Tailwind uses. The 1.32.0 Windows and Linux binaries remain in the lockfile.
  • Documented in .env.example that the contract ID is optional and that the API URL must be public in deployments.

Verification

  • env.test.ts and useNetworkGuard.test.ts: 25/25 pass.
  • next build with NEXT_PUBLIC_CONTRACT_ID unset succeeds and prints the warning.
  • Lint is clean. Source type-check has no new errors; the pre-existing errors in test files are unchanged.
  • Not done: no browser test against a live deployment.

🤖 Generated with Claude Code

Godsmiracle001 and others added 2 commits October 27, 2026 22:37
…ry page

The production schema required NEXT_PUBLIC_CONTRACT_ID and validateEnv()
threw when it was absent. That check runs in the browser at bundle load
(NODE_ENV is "production" there), not only at build time, so a deployment
without the variable crashed every route, including the public landing
page. No frontend code signs against this value; transactions are built by
the backend from its own CONTRACT_ID.

A missing or empty value now warns instead of throwing. A malformed value
still throws. The production-throw test is replaced with one asserting the
new behaviour, plus tests for the empty and malformed cases.

Also drop the root optionalDependencies pin on lightningcss-win32-x64-msvc
^1.33.0. It did not match the lightningcss 1.32.0 that Tailwind uses, so it
installed an unused Windows binary at a second version. The correct 1.32.0
Windows and Linux binaries remain in the lockfile.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Oct 27, 2026

Copy link
Copy Markdown

@Godsmiracle001 is attempting to deploy a commit to the mimijuwonlo-8913's projects Team on Vercel.

A member of the Team first needs to authorize it.

@mimijuwonlo-commits
mimijuwonlo-commits merged commit 1712148 into Split-Naira:main Oct 27, 2026
5 of 10 checks passed
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