🔎 What you'll see
GitHub alert email: "secret detected" / sudden usage spike
🤔 Why it happens
An API key is like a password. Put it in HTML or JavaScript and anyone can read it with View Page Source. Push it to GitHub and bots can scrape it and abuse it within minutes. If a payment method is attached, you could end up with a huge bill.
🛠️ How to fix it
- First, go to that service's dashboard, delete (revoke) the key and create a new one. Removing it from your code isn't enough — it's still in the history.
- Keep the new key only in environment variables on a server (or serverless function), never in browser code.
- Add your .env file to .gitignore so it never gets pushed to GitHub.
- If the service lets you set a usage limit, set one.
🤖 What to ask your AI
Replace the parts in [ ] with your own details, then paste it in.
I want to get my API key out of browser code and use it safely. Right now I call the [service name] API like this: [code]. Walk me step by step through the simplest setup and code for moving the key into a server-side environment variable. I'm a beginner.
Other errors
CORS errorThe browser blocks your page from fetching data from another site404 Not FoundThe address or file can't be foundundefined / Cannot read properties of undefinedReading a property of a value that isn't thereis not definedUsing a name that was never declaredSyntaxErrorBrackets or quotes don't match upMixed ContentAn https page loads something from an http addressBlank white pageYou deployed it and all you see is a blank screenis not a functionCalling something that isn't a functionUnexpected token < in JSONYou expected JSON but got HTMLCannot use import statement outside a moduleThe browser won't accept your import statementfavicon.ico 404The console shows a 404 for favicon.icoData disappears when I refreshYour to-dos or scores aren't being savedPage looks broken or tiny on phonesFine on a computer, weird on mobilegit push rejectedA "rejected" / non-fast-forward errornpm: command not foundYour terminal says npm or node doesn't existPort 3000 is already in useYour dev server says the port is takenEnvironment variables (.env) aren't loadingYou put your API key in .env but it comes out undefinedThe AI keeps failing to fix the same errorYou ask for a fix and nothing changes