CORS (Cross-Origin Resource Sharing) is a browser security feature that controls which websites can make API requests to your server. By default, browsers block requests from different domains (example.com can't call api.otherdomain.com) unless the API explicitly allows it via CORS headers. Prevents malicious sites from stealing data from your API.
Configure CORS on all APIs that are called from browsers (not needed for server-to-server APIs). For public APIs, allow all origins (*). For private APIs, whitelist specific domains (app.yourcompany.com). Never use * for APIs with authentication—attackers can steal tokens. Use CORS libraries in your framework (Express cors, Next.js API routes, Django CORS headers).
Cybersecurity
Control which websites can call your API