Esc
  • Jump to
  • The board
  • All launchesSort and filter by week or category
  • Open statsEvery number, in public
  • Maker storiesApps that stopped hiding
  • Submit a launch
  • AICategory
  • AnalyticsCategory
  • API & BackendCategory
  • Audio & VoiceCategory
  • AutomationCategory
  • CommunityCategory
↑↓ to move↵ to openPress / anywhere
Sign in

What is Cross-Origin Resource Sharing (CORS)?

An HTTP-header protocol that lets a server declare which external web origins a browser may allow client-side scripts to read responses from.

Updated · Building

Plain definition

Definition of Cross-Origin Resource Sharing (CORS)

An HTTP-header protocol that lets a server declare which external web origins a browser may allow client-side scripts to read responses from.

Formula / syntaxBrowser (Origin A) -> OPTIONS Preflight (if non-simple) -> Server (Access-Control-Allow-Origin) -> Actual Request

Worked example

Say a founder ships a made-up embeddable feedback widget called NoteDrop whose web dashboard runs at `https://app.notedrop.example` while its API runs on `https://api.notedrop.example`. Even though both share a root domain, different subdomains count as different origins under the browser's same-origin policy. When dashboard JavaScript calls `fetch("https://api.notedrop.example/v1/boards", { method: "POST", headers: { "Content-Type": "application/json", "Authorization": "Bearer ..." } })`, the browser first sends an `OPTIONS` preflight request asking if `POST` and `Authorization` are permitted from `https://app.notedrop.example`.

The NoteDrop API answers the `OPTIONS` request with `204 No Content`, `Access-Control-Allow-Origin: https://app.notedrop.example`, `Access-Control-Allow-Methods: GET, POST, DELETE`, `Access-Control-Allow-Headers: Content-Type, Authorization`, and `Vary: Origin`. Only then does the browser fire the real `POST` call and expose its JSON response to NoteDrop's frontend code.

Why it matters when you launch

As MDN explains, browsers enforce the same-origin policy on `fetch()` and `XMLHttpRequest` so random tabs cannot silently read your private authenticated responses from another site. Whenever you split your frontend and API across separate domains, serve a Chrome extension, or ship an embeddable widget on customer websites, misconfigured CORS headers will block legitimate requests on launch morning. Knowing the difference between simple requests (such as plain `GET` requests with standard headers) and preflighted `OPTIONS` requests helps you debug failures quickly in browser DevTools.

Two security rules matter just as much as getting requests unblocked. First, never combine `Access-Control-Allow-Credentials: true` with wildcard `*` (browsers reject it, and echoing arbitrary `Origin` headers blindly leaks authenticated data to any attacker site). Second, remember that CORS is strictly a browser boundary: `curl`, Python scripts, and backend servers ignore CORS headers completely, so every endpoint still needs real authentication.

Common mistakes

  • Reflecting the incoming `Origin` header verbatim alongside `Access-Control-Allow-Credentials: true`, letting any malicious site read authenticated user data.
  • Using `Access-Control-Allow-Origin: *` on endpoints that expect cookies or `Authorization` credentials, causing browser preflight failures.
  • Treating CORS rules as API access control while forgetting that command-line tools and server scripts bypass browser CORS checks entirely.
  • Forgetting `Vary: Origin` when returning per-origin CORS headers behind a CDN, poisoning cached responses across different calling domains.

Tools and guides that use it

Official sources

Pritam Ghosh runs Hauntboard and maintains this glossary.

Published · Updated

Building something real? Launch it in public.

A person reviews every launch on Hauntboard, and every view and visit it sends your site is published on your launch page. Free to submit.

Launch free →

On the board

All →

Still hiding your app?

Put it on the board. Reviewed by a person, free to launch.

Launch free
Submit a launch