# CORS Preflight and SameSite Cookie Boundaries vs Cross-Origin Isolation with COOP and COEP

- **Canonical URL:** https://frontend.rocks/vs/cors-preflight-samesite-vs-cross-origin-isolation-coop-coep/
- **Relation:** Contrasts With
- **Last Verified:** 2026-11-15
- **Verdict:** CORS governs JS response readability; COEP/CORP governs embedding binary resources in isolated processes.

## Comparison Matrix

| Dimension | CORS Preflight and SameSite Cookie Boundaries | Cross-Origin Isolation with COOP and COEP |
| :--- | :--- | :--- |
| **Maturity** | Baseline · Widely | Baseline · Widely |
| **Domain** | Security & Accessibility | Security & Accessibility |
| **Mental Model** | Fetch-layer cross-origin read gating via OPTIONS preflight handshakes, paired with SameSite cookie attributes that restrict cross-site credential attachment. | Process-level browser isolation enabled by Cross-Origin-Opener-Policy and Cross-Origin-Embedder-Policy headers, unlocking SharedArrayBuffer and high-resolution timers by blocking unverified cross-origin bytes. |
| **Prerequisites** | None | CORS Preflight and SameSite Cookie Boundaries (COEP relies on CORS or Cross-Origin-Resource-Policy opt-ins before loading cross-origin subresources.) |
| **When Not to Use** | When not to use SameSite=None: Never set SameSite=None on session cookies unless a third-party iframe genuinely requires them; SameSite=Lax protects standard first-party apps against CSRF. | When not to use Cross-Origin Isolation: Standard CRUD apps that do not run multi-threaded Wasm (SharedArrayBuffer) gain little from COOP/COEP while paying steep third-party embed compatibility costs. |

## CORS Preflight and SameSite Cookie Boundaries — Under the Hood
CORS is a bouncer checking whether JavaScript may *read* the response; `SameSite` is the lock on your wallet deciding whether cookies even leave your pocket on a cross-site trip.

1. **Simple vs Preflight**: `GET`/`POST` with `text/plain` or `application/x-www-form-urlencoded` skips preflight; `application/json` or `Authorization` triggers an `OPTIONS` handshake first, including on cross-origin [Beacon API](/concepts/beacon-api-visibilitychange) calls.
2. **Wildcard Ban with Credentials**: When `credentials: 'include'` is set, `Access-Control-Allow-Origin: *` is rejected; the server must echo the exact verified origin and set `Vary: Origin`.
3. **Site vs Origin**: `SameSite` checks the **eTLD+1** (`app.example.com` and `api.example.com` are *same-site*, though *cross-origin*), whereas CORS and [Cross-Origin Isolation](/concepts/cross-origin-isolation-coop-coep) enforce strict `(scheme, host, port)` origin equality.

```http
HTTP/1.1 204 No Content
Access-Control-Allow-Origin: https://app.example.com
Access-Control-Allow-Credentials: true
Access-Control-Allow-Methods: POST, OPTIONS
Access-Control-Allow-Headers: Content-Type, Authorization
Access-Control-Max-Age: 7200
Vary: Origin
```

## Cross-Origin Isolation with COOP and COEP — Under the Hood
COOP and COEP work like a cleanroom airlock: COOP locks the side door so cross-origin popups cannot share your process, and COEP inspects every incoming crate so no uninvited cross-origin bytes enter your memory space.

1. **COOP (`same-origin`)**: Severs `window.opener` references to cross-origin windows, forcing separate browsing context groups and OS processes.
2. **COEP (`require-corp`)**: Blocks any cross-origin image, script, iframe, or [CORS](/concepts/cors-preflight-samesite) fetch that lacks `Cross-Origin-Resource-Policy: cross-origin` or valid CORS headers.
3. **Unlocked Primitives**: Once `crossOriginIsolated` is `true`, the engine exposes [SharedArrayBuffer](/concepts/shared-array-buffer-atomics) and sub-millisecond `performance.now()` precision.

```http
Cross-Origin-Opener-Policy: same-origin
Cross-Origin-Embedder-Policy: require-corp
```

## Interactive Labs & Dissections
- [CORS Preflight and SameSite Cookie Boundaries Lab](https://frontend.rocks/concepts/cors-preflight-samesite/#lab) ([Markdown](https://frontend.rocks/concepts/cors-preflight-samesite.md))
- [Cross-Origin Isolation with COOP and COEP Lab](https://frontend.rocks/concepts/cross-origin-isolation-coop-coep/#lab) ([Markdown](https://frontend.rocks/concepts/cross-origin-isolation-coop-coep.md))

## Related Architecture Autopsies
- [Autopsy #11: Anatomy of a Supply-Chain DOM XSS & How Trusted Types Stop It](https://frontend.rocks/autopsies/third-party-script-xss-takeover/) ([Markdown](https://frontend.rocks/autopsies/third-party-script-xss-takeover.md)): Compromised third-party widget injects an inline script via an innerHTML sink and exfiltrates session tokens.

## Primary Sources
- https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/CORS
- https://fetch.spec.whatwg.org/#http-cors-protocol
- https://developer.mozilla.org/en-US/docs/Web/API/Window/crossOriginIsolated
- https://html.spec.whatwg.org/multipage/browsers.html#cross-origin-opener-policies
