Node.js · Junior · Question 75 of 75
Why should secrets like database passwords not be hard-coded in the source?
- 1Hard-coded strings make Node.js slower
- ✓Correct answer: Code ends up in git, logs and builds; secrets belong in environment variables or a secret manager
- 3Node.js does not allow strings longer than 32 characters in source files
Explanation
A secret committed once stays in git history. Keep .env files out of git and rotate any secret that was ever committed.