0

I am trying to use env-cmd to load environment variables in next js

"scripts": {
"dev": "env-cmd -f .env.build next dev -p 3006",
"build": "env-cmd -f .env.build next build",
"start": "next start -p 3006",
"lint": "next lint",
}

However, it is unable to load the environment variables in the code

const programUrl  = process.env[`PROGRAM_URL`] as string;

This line is running on the browser and the value is undefined, the .env.build has that particular environment variable.

How could this be debugged ?

africandrogba
  • 334
  • 1
  • 3
  • 21

0 Answers0