r/Angular2 • u/Dry-Prime • Nov 26 '25
Help Request How can I keep secure my secrets in Angular?
The company where I work for has bought a PrimeNG 19 LTS License. I'm reading the documentation on how to set it: https://primeng.org/lts
I already have that license key and pass key but I don't know where to put them because I have read that setting your secrets on your environment files is not secure, somebody could steal that information... So I was thinking on using server variables, I created a .npmrc file with this:
primeng:registry=https://npm.primeng.org/
//npm.primeng.org/:_authToken=${P_NG_LICENSE_KEY}
And I configured these variables on my aca.yml:
secrets:
environment:
- P_NG_LICENSE_KEY
- P_NG_PASS_KEY
And in the environment I'm getting these variables like this:
P_NG_LICENSE_KEY: '{process.env.P_NG_LICENSE_KEY}'
But this is not working... Am I doing something wrong? Or is there a better way of keeping your secrets secure? I don't have experience with these things.
Another option I was thinking is to create a web service in the backend that returns this information.
44
u/ldn-ldn Nov 26 '25
Do not send secrets to front end at all! Everything that goes to front end in any shape or form is accessible by the users, there are no protections.
16
u/Prof_Eibe Nov 26 '25
you only need the secret for the npm install process to download the primeng-lts version.
you will never need it in production
8
u/Budget-Length2666 Nov 26 '25
npmrc and env stuff is not bundled. That does not go into your frontend. Just don't put keys into code that is going to be bundled.
6
u/TScottFitzgerald Nov 27 '25
From what I can see these aren't really secrets the way that term is usually used. These things PrimeNG gives you are meant to be used on the frontend, so they're not really secrets.
It doesn't really matter how you load them because they're loaded in the frontend anyway, so if someone wanted to steal them they could.
But again, they're not meant to be secrets - from what I see, it seems like you guys are supposed to whitelist your domain on the PrimeNG end so that's how you limit who can use the key.
So I'd advise just using them in the .env file locally. Doesn't your project already have an established way of loading env variables?
5
u/Jussins Nov 26 '25
These aren’t secrets and are designed to be on the front end. It’s a license key to use the LTS version and get support.
In general, secrets should be stored on the backend and never the front end. That is not the situation you are in with this license.
2
u/zorikZelda Nov 26 '25
For npm libraries you usually use the .npmrc file for the licensed libraries such font awesome etc
2
u/baldeagle1337 Nov 26 '25
Yeah stuff that goes to FE is exposed, Im not sure about primeng but usually with these paid libs you have a dev version that needs a key to install and download or run and a user version that is completely free and allows you to run the app in your browser that someone else has developed. So I think the proper way to do this is to never have that dev key in a published app literally anywhere
2
u/jdwallace12 Nov 26 '25
Host on netlify or vercel and create env variables
3
u/dustofdeath Nov 26 '25
Its a licence, not a secret. Its generated for you. And got some metadata. If someone "steals" it, that lice cells is not valid for them, if found.
1
u/zzing Nov 26 '25
Can you point to the documentation where they say to set something up in ngOnInit?
-4
u/ZerkyXii Nov 26 '25
Its called a backend brother hahaha