Secrets

API keys written in the source

Keep API keys and tokens out of source files, and load them from environment variables instead.

Why it matters

A key in the source is copied to every developer machine, every backup, and often every build. Deleting it later does not remove it from history.

If the repository leaks, the key is used on your account. Moving it to an environment variable is a small change now and a large saving later.

How to fix it

  1. Search the repository for key-like strings

  2. Move each key to an environment variable

  3. Add the secret file to .gitignore

  4. Rotate any key that was ever committed

Prompt for an AI assistant

Copy the text below and paste it into an AI assistant.

You are the person improving this website. Check the item below and fix it if it applies to the site.

Item: API keys written in the source
Summary: Keep API keys and tokens out of source files, and load them from environment variables instead.
Steps:
1. Search the repository for key-like strings
2. Move each key to an environment variable
3. Add the secret file to .gitignore
4. Rotate any key that was ever committed
References:
- Secrets Management (OWASP) (https://cheatsheetseries.owasp.org/cheatsheets/Secrets_Management_Cheat_Sheet.html)

Constraints:
- Keep the existing design and tone of voice.
- Show the file or section you changed and the suggested final wording.
- Do not decide ambiguous points alone; give options and a recommendation.
- Do not change anything outside the listed item.

Related checks

References

Check your site now

Enter a URL and find what is missing before launch, for free.

Run audit