AI websites

Step-by-step tutorial

How to Check an AI Website for Exposed API Keys Before Publishing

Check the files your site will publish for private API keys, learn what belongs on the server, and know what to do if a key is already exposed.

Product links on this page are ordinary official links. No affiliate commission is currently attached. Read our disclosure.

Quick answer

Check the finished files visitors will receive. If a private API key appears in the HTML, a script, or a downloadable configuration file, stop the release. If the key has already been shared or deployed, revoke or rotate it in the provider’s dashboard and then remove the exposed copy. Deleting it from your next build cannot take back a copy someone already saved.

An API key is a credential a service gives your app. Some services explicitly provide a publishable browser key, while others issue private keys that belong on the server. Use the provider’s documentation to tell them apart before changing anything.

Find out what the host will publish

Ask your coding assistant to identify the build output folder and the folder your host serves. On some sites, it is an output folder such as dist. If you upload plain HTML directly, it may be the exact folder you upload. Check the actual folder for your site.

Open that output or a local preview. Check the HTML, JavaScript and any configuration or backup files copied there. A value can also appear in a request sent by the browser, so check the browser’s Network panel when the feature runs. Start with the feature that uses the credential, such as a page that calls a service, rather than trying to read every script.

Where you find it What to check
Source configuration Is the setting intended only for a server, or does the build send it to the browser?
Finished HTML or script Would a visitor receive a private value with the page?
File you can download from the preview Did a backup or configuration file get copied into the public output?

Ask for locations without exposing the values

Inspect only the files and requests this site sends to a visitor.
Report the file names and setting names for possible private keys.
Mask every value. Do not print or copy any actual credential.
Show where the website uses each setting and propose a small fix.
Do not upload, publish or change any keys.

Use a dummy value if you need to reproduce the problem. A name like PUBLIC_ can be a useful clue. For example, Astro documents which variables it makes available to client code. Naming conventions differ across tools. A setting stored in an environment file can still end up in public output if the build puts it there.

Fix the path, then test the feature

If a feature needs a private key, put the call that uses it on a backend or use a supported integration that keeps the key server-side. A static page alone cannot keep a secret that its own browser code needs. If the feature is not ready, remove it from the public build while you work on the server-side version.

If the key was exposed in a Git repository, GitHub’s guidance starts with revoking or rotating the credential. An earlier commit can still contain the value. Check the provider’s activity and usage controls if available. Follow your safe website update steps with a clean build.

Finish when the identified private value no longer reaches the browser and the feature still works with the intended permissions. This check helps catch a specific mistake. It does not replace a security review of the whole site.