# Secrets in client JavaScript
*Secrets*
Keep API keys and tokens out of the JavaScript that browsers download.

## Why it matters
Anything sent to the browser can be read by anyone. A key in front-end code is not hidden; it is published.
The usual damage is a bill from a third-party API or access to data the key allows. Moving the call to the server removes the exposure.

## How to fix it
1. Search the built JavaScript for key-like strings
2. Move privileged calls behind your own server
3. Use short-lived tokens and restrict them by origin or scope
4. Rotate any key that was shipped to the browser

## Prompt for an AI assistant
Copy the text below and paste it into an AI assistant.
```text
You are the person improving this website. Check the item below and fix it if it applies to the site.

Item: Secrets in client JavaScript
Summary: Keep API keys and tokens out of the JavaScript that browsers download.
Steps:
1. Search the built JavaScript for key-like strings
2. Move privileged calls behind your own server
3. Use short-lived tokens and restrict them by origin or scope
4. Rotate any key that was shipped to the browser
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.
```

## Checked by
- **[vuln](https://ismyappok.com/en/vuln/checks)** — Public exposure checks

## Related checks
- **[.env file exposure](https://ismyappok.com/en/checks/env-file-exposure)** — Make sure .env and other secret files cannot be downloaded from the public site.
- **[Source map exposure](https://ismyappok.com/en/checks/source-map-exposure)** — Do not publish source maps that contain your original source code.

## References
- **[Secrets Management (OWASP)](https://cheatsheetseries.owasp.org/cheatsheets/Secrets_Management_Cheat_Sheet.html)** — OWASP cheat sheet（Reference）

## Check your site now
Enter a URL and find what is missing before launch, for free.
[Run audit](https://ismyappok.com/en/audit/check)