1. What It Is

CORS is a browser security mechanism that controls which web origins (domain + scheme + port) are allowed to make HTTP requests to your backend API.

The problem it solves: Browsers enforce a Same-Origin Policy by default — JavaScript running on https://app.example.com cannot fetch data from https://api.otherdomain.com. This blocks a huge class of cross-site attacks. But it also blocks legitimate use cases, like your React SPA talking to your own API on a different subdomain. CORS is the standardized way to selectively relax that restriction.

Why you should care: Almost every modern web app uses a separate frontend and backend domain. If you don't configure CORS correctly, your own users get blocked. If you configure it too loosely, you open up security vulnerabilities. Backend engineers need to understand both sides.


2. How It Works in Practice

The Two Types of Requests

Simple requests (GET/HEAD/POST with plain text or form data, no custom…

In the full tutorial

  • 3. Common Real-World Usage
  • 4. Trade-offs and Common Mistakes
  • 5. Interview Angle
  • 6. Practical Examples

Glossary history

Click dotted jargon to save explanations here.