Angular SSR Environment variables

Hello,

I have an Angular 19 application deployed, which utilizes the environment.ts and environment.production.ts files to manage secrets and URLs. To handle these securely, I created the necessary environment variables within my Vercel project settings. However, when attempting to load the application, I encounter an error indicating that the specified environment variable could not be found.

Uncaught ReferenceError: process is not defined at environment.ts at urlBackend: process.env.NG_APP_API_URL

The error isn’t actually about the environment variable, but if you read closely you’ll see it says process is the thing that’s not defined.

process is a node global that will only exist serverside, so it’s possible you’re seeing this error because it’s trying to run this code in the browser instead of at build time

I don’t know Angular too well, but it appears to not have built in support for reading real environment variables and people seem to be using this lib to solve it

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.