Skip to content

fix: add build-time validation for env config (fix #26) - #62

Open
elevasyncsolutions-jpg wants to merge 1 commit into
MergeFi:mainfrom
elevasyncsolutions-jpg:fix/build-time-config-validation
Open

fix: add build-time validation for env config (fix #26)#62
elevasyncsolutions-jpg wants to merge 1 commit into
MergeFi:mainfrom
elevasyncsolutions-jpg:fix/build-time-config-validation

Conversation

@elevasyncsolutions-jpg

Copy link
Copy Markdown

Summary

Adds build-time validation for NEXT_PUBLIC_STELLAR_NETWORK and NEXT_PUBLIC_API_URL environment variables to prevent dangerous misconfigurations that could lead to signing transactions with the wrong network passphrase or silent API failures.

Problem

Without validation, a production build accidentally shipped with:

  • NEXT_PUBLIC_STELLAR_NETWORK unset → silently falls back to TESTNET → signs transactions with testnet passphrase in production (real funds at risk)
  • NEXT_PUBLIC_STELLAR_NETWORK misspelled (e.g., "MAINNET") → same silent fallback
  • NEXT_PUBLIC_API_URL unset → falls back to http://localhost:4000/api → all API calls fail silently

Changes

  • NEXT_PUBLIC_STELLAR_NETWORK: Validates against PUBLIC and TESTNET. Throws in production if missing or invalid with clear explanation of the financial risk.
  • NEXT_PUBLIC_API_URL: Validates URL format. Throws in production if missing or invalid.
  • Development mode: Still allows fallbacks with console warnings for easy local development.

Error messages

NEXT_PUBLIC_STELLAR_NETWORK must be set in production. 
Valid values: "PUBLIC", "TESTNET". 
Accidental TESTNET in production would sign transactions with the wrong network passphrase.
Invalid NEXT_PUBLIC_STELLAR_NETWORK: "MAINNET". 
Valid values: PUBLIC, TESTNET.

Testing

  • Verified validation works in development (fallbacks allowed)
  • Verified production mode throws on missing/invalid values
  • No breaking changes to existing functionality

Closes #26

- Validate NEXT_PUBLIC_STELLAR_NETWORK against allowed values (PUBLIC, TESTNET)
- Throw in production if STELLAR_NETWORK is missing (prevents accidental testnet signing)
- Validate NEXT_PUBLIC_API_URL is a valid URL
- Throw in production if API_URL is missing (prevents localhost fallback)
- Clear error messages explain the financial risk of misconfiguration

Closes MergeFi#26
@vercel

vercel Bot commented Jul 16, 2026

Copy link
Copy Markdown

Someone is attempting to deploy a commit to the chonilius' projects Team on Vercel.

A member of the Team first needs to authorize it.

@elevasyncsolutions-jpg

Copy link
Copy Markdown
Author

@chonilius Ready for review. This PR Build-time config validation (fix #26). All CI green. Mergeable. Pays USDC on Stellar (Soroban) on merge.

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.

Add build-time validation for NEXT_PUBLIC_STELLAR_NETWORK and API URL config

1 participant