How to securely manage environment variables in Angular app deployment

  Kiến thức lập trình

I have a enviroment.ts file

export const environment = { token: '345' };

and a enviroment.developement.ts file

export const environment = { token: '123' };

both are on public github repo. I want to deploy an app and set token value as real key value, but using enviroment variables on netlify or vercel doest work as I set them for the project. I dont want to write in any part of my app the real access token. How to deploy the app and change the fake token value with real value? If i put the real value in src/environments/environment.development.ts it will be public available but i have to do it since its the place where netlify or vercel take code from.

If i add:

  production: true,
  token: '345',

the values still are not changed.

Following:
https://angular.io/guide/build#configure-target-specific-file-replacements

LEAVE A COMMENT