🔎 What you'll see
Access to fetch at '...' from origin '...' has been blocked by CORS policy
🤔 Why it happens
For security, when your page asks a server on a different address (domain) for data, the browser blocks the response unless that server sends back a header saying it's allowed (Access-Control-Allow-Origin). Often your code isn't wrong at all — it's the other server's settings.
🛠️ How to fix it
- Check the API's docs to see whether it can be called directly from a browser (most public APIs allow it).
- If it doesn't, call it through your own server (backend) instead: browser → your server → their server.
- If you built that server yourself, add the Access-Control-Allow-Origin header to its responses.
- If you opened the file by double-clicking it (a file:// address), try a simple local server or your deployed URL instead.
🤖 What to ask your AI
Replace the parts in [ ] with your own details, then paste it in.
I'm getting a CORS error in the browser console. Here's the message: [paste the message]. My code calls [which API, from where]. Can this API be called directly from the browser? If not, walk me through the simplest way to call it through a server, step by step.
Other errors
404 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 upExposed API keyYou put a secret key in your code or on GitHubMixed 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