Skip to content

[S4] Add environment variable validation to the frontend on startup #798

Description

@Akshola00

Description

The frontend relies on NEXT_PUBLIC_API_BASE_URL being set at build time, but if it is missing the app silently makes requests to undefined which produces confusing network errors.

Add a startup check that validates all required public env vars and throws a clear error during build if any are missing.

Deliverables

  • Create lib/env.ts that reads and validates required env vars (NEXT_PUBLIC_API_BASE_URL, NEXT_PUBLIC_STELLAR_NETWORK)
  • If a required var is missing, throw with a message like: Missing required env var: NEXT_PUBLIC_API_BASE_URL
  • Import and call the validation in lib/api-client.ts so it fails at module load time, not silently at runtime
  • Add a .env.example file at nevo_frontend/ listing all required vars with placeholder values
  • npm run build still passes with the vars present

Notes

No new dependencies needed — plain TypeScript is fine. Do not use zod unless it is already in the project dependencies.

Metadata

Metadata

Assignees

Labels

EasyFrontendStellar WaveIssues in the Stellar wave programstage-4Frontend-Backend integration

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions