Web and networkingDive 06 of 12
CORS, at the browser’s boundary
Your app can reach the API. Why can’t it read the reply? Follow one JSON order through origins, preflights, cookies and the browser’s response filter, down to HTTP/2 frames.
- Levels
- 8
- Reading
- 38 min
- Depth
- Idea to Machine
- Published
The same order. Two server replies. CORS decides whether your app may read the result.
POST https://api.example/ordersJSON + Authorization + credentials: includeA wildcard that fails
Browser asks with OPTIONS
Access-Control-Allow-Origin:
*Access-Control-Allow-Credentials: trueNo explicit header permission
authorization, content-type missing× POST stopped at preflight
JavaScript gets TypeError
Permission for this app
Browser asks with OPTIONS
Access-Control-Allow-Origin:
https://app.exampleAccess-Control-Allow-Credentials: trueAccess-Control-Allow-Headers:
authorization, content-type✓ POST sent · response readable
JavaScript gets {"order":42}
Computed with the same Fetch rules as the labs below. A server reply grants access; a client header cannot grant itself access.
Your browser brings authority with it
Your checkout lives at https://app.example. Its API lives athttps://api.example. You click “Place order.” The page sends JSON, adds an Authorization header, asks to include cookies, and then reportsFailed to fetch
. DevTools says CORS. Yet the API works with curl, its TLS certificate is valid, and both services belong to you.
The missing piece is the browser’s trust boundary. curl runs with the authority of the person who launched it. A web page runs code supplied by whichever site you opened a moment ago. Your browser must let that code do useful work without giving it access to everything else you are logged into. TheA family of browser restrictions that keeps one origin from freely reading or manipulating another origin’s resources.is the foundation. CORS, Cross-Origin Resource Sharing, is a protocol through which a server can grant a particular kind of exception: permission to expose a cross-origin response.
Imagine there were no boundary. You log into the API, which remembers you with a session cookie. Later you open an attacker’s page. Its script fetches your orders, the browser supplies the API’s cookie, and the script reads the response and copies it elsewhere. The attacker never needed your password or the cookie value. They borrowed the browser’s ability to act as you.
That ability isAuthority attached to the surrounding environment rather than explicitly handed to each caller: cookies and access to an internal network are examples.. Cookies are one source. Network position is another: a page running on your laptop may be able to reach an intranet service that the attacker cannot reach directly. A server that trusts “requests from inside the office” must consider that an untrusted page can run inside the office too. CORS controls response exposure; it does not make that network position safe to trust.
The attacker chooses the script. Your browser supplies the reach.
Does not know the API session secret
May sit inside a private network
SOP withholds it from an unapproved origin
Origin is a tuple, not an owner
For ordinary HTTPS URLs an origin consists of scheme, host and effective port.https://app.example:443 and https://app.example have the same origin because 443 is HTTPS’s default port. Change the host toapi.example, the scheme to HTTP, or the port to 8443 and you have another origin. Change only the path, query or fragment and you do not. Domain ownership, DNS aliases, the destination IP and the server process are absent from the comparison. Two hosts resolving to the same IP remain separate origins.
This is why a reverse proxy can change the situation. If the browser callshttps://app.example/api/orders and that server forwards the request to your API, the browser-facing request stays same-origin. You have moved the integration to a server you control. That can be a good architecture, but it also moves responsibility for authentication, caching and upstream access there. Giving both frontends the same IP address achieves none of that.
A site is a different grouping. For these HTTPS domain examples it is the scheme plus the registrable domain, determined using the Public Suffix List. A suffix can be co.uk or a hosting provider’s private suffix, so “take the last two labels” is not a general algorithm. Ports disappear from the site comparison. Sites matter to cookies and storage partitioning; origins matter to CORS and DOM access. SeeHTML’s origin definitionand itssite computation.
Origins keep ports. Sites keep registrable domains.
Origin comparison: different
Site comparison: different
Different host; different registrable domain.
app.example and api.example are cross-origin and cross-site. For same-site siblings, select the shop.example example.
Preset registrable domains follow the PSL default rule for .example. This is a comparison of known examples, not a general-purpose PSL implementation.
Some origins do not have a tuple
A sandboxed iframe without allow-same-origin can have anopaque origin. A data: document also provides a useful example. An opaque origin is an internal identity, not an address you can reconstruct. Its serialized form is the string null. Distinct opaque origins can both serialize as null without being the same origin. Accepting that string in a server allowlist therefore does not identify a single trusted application.
Keep the browser and the server’s jobs separate from the beginning. The browser tracks the origin of the code making the request. The server decides whether that origin may receive its response, and independently decides whether the user may place this order. A CORS grant says nothing about which account owns order 42, whether a bearer token is valid, or whether a request should charge a credit card.
The browser separates the authority of your session from the authority of whatever page you just opened.
Sending and reading are different powers
It is tempting to translate a CORS error as “the browser refused to contact the API.” Sometimes that is true. Sometimes the API has already processed the request and the browser merely refuses to show its response. Debugging safely means learning to distinguish those cases before clicking “Place order” again.
The web needed cross-origin sending long before it had fetch(). A page can link to another site, navigate a window, embed an image, and submit a form to another origin. If browsers had forbidden all such requests, the web would not have worked. The restrictions instead grew around what the initiating page could read or manipulate afterwards. A page can display a cross-origin photograph without gaining unrestricted access to its pixels through canvas. It can embed a frame without gaining access to the frame’s DOM.
For the API this distinction is concrete. An attacker can construct an ordinary form with method="post" andaction="https://api.example/orders". Form encoding is constrained, but the submission can reach the API. Eligible cookies may travel. The attacker normally cannot read the resulting cross-origin document, yet an endpoint that changes state merely because it receives that form can still perform an unwanted action.
That isAn attacker causes a victim’s browser to send an authenticated request the victim did not intend, often without needing to read its response., or CSRF. A response read barrier cannot undo a database write. Protect cookie-authenticated mutations with an appropriate combination of CSRF tokens, Origin validation, SameSite cookies and request-context checks. Validate these on the server. Their role is to reject an unwanted action, including cases where the attacker will never see the answer.
| Operation | What may happen | What stays restricted |
|---|---|---|
| Link or top-level navigation | Browser opens another origin | Old page does not gain the new page’s DOM |
| HTML form POST | Constrained body can reach another origin | Initiating script cannot freely read the reply |
| Image or classic script | Resource can be embedded, subject to its own policies | Image pixel readback is tainted without approval; classic scripts execute as code |
| Module script | Loaded using CORS | No general classic-script exemption |
| Cross-origin iframe | Document can render unless framing policy forbids it | DOM, JS objects and storage stay isolated |
| CORS fetch | Approved request can expose a response | Server must grant the requesting origin access |
| no-cors fetch | Restricted request may be sent | Opaque response hides status, headers and body |
CORS is a narrow exception
Giving the app permission to read /orders does not make the app and API the same origin. It does not unlock iframe.contentDocument, combine their IndexedDB databases, merge their localStorage, or grant a service worker control over the other host. Cross-window communication uses mechanisms such as postMessage, with explicit validation of the sender origin and a specific target origin. Each API keeps its own security contract.
Storage can have a second boundary too. Browsers can partition a third-party origin’s storage by its top-level site, so the same embedded origin does not automatically receive the same state on two unrelated sites. Partitioning policy varies by storage API and browser. An Allow-Origin response header does not override it. Do not infer a storage guarantee from a successful fetch.
“no-cors” means less access
Changing our fetch to mode: "no-cors" restricts the author headers and methods. It does not instruct the API to ignore security. In particular, it cannot preserve our arbitrary Authorization header or JSON Content-Type as an escape hatch. The browser’s request header guard drops fields that mode does not permit. If an allowed request succeeds, the cross-origin response isopaque: the exposed status is 0, the exposed headers are empty, and the exposed body is null.
That exposed status is not the status the server sent. An internal 200 and an internal 404 can both be hidden behind the same opaque interface. A Service Worker may store an opaque response for later resource use, but that does not let script open it and inspect the bytes. Browser protections such as resource policy and opaque response blocking can still reject the load itself.
Finally, a response that passes CORS still has a filtered header view. Script can read the safelisted response fields, including Content-Type and Content-Length. A custom X-Order-Id requiresAccess-Control-Expose-Headers. Set-Cookie remains a forbidden response header even if you explicitly list it. The browser’s cookie machinery may process it under its own rules while page JavaScript remains unable to read it. These are theCORSandopaque filtered responsedefinitions. If Access-Control-Expose-Headers cannot be parsed as a field-name list, Fetch ignores the entire extra list. The safelisted response headers and an otherwise CORS-readable body remain available; a malformed exposure field is not a CORS network error.
A readable body can still have hidden headers
Server response headers
content-type: application/json x-order-id: 42 x-trace: abc set-cookie: session=secret; Secure; HttpOnly
JavaScript response.headers
content-type: application/json x-order-id: 42
content-type is safelisted; x-order-id is explicitly exposed. Set-Cookie stays hidden.
Sending, embedding, executing and reading are distinct powers. CORS grants response access; it does not merge origins.
Why this POST needs permission first
Return to the checkout. The app asks for a POST containing JSON, an Authorization header and eligible API cookies. The browser can recognize that this is outside the set of requests old HTML forms could freely construct. Before sending it, the browser checks whether the API understands and accepts the CORS protocol for this request shape.
const response = await fetch("https://api.example/orders", {
method: "POST",
mode: "cors",
credentials: "include",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer demo",
},
body: JSON.stringify({ sku: "book", quantity: 1 }),
});
// CORS errors reject fetch; HTTP 401/500 do not.
if (!response.ok) throw new Error(`API returned ${response.status}`);
const order = await response.json();A request commonly called “simple” is one that does not need this preflight under the usual fixed-body Fetch path. The standard uses more precise terms:CORS-safelisted methods andCORS-safelisted request headers. The method must be GET, HEAD or POST. The header test depends on both the field name and the value; a familiar header name alone does not make a request safelisted.
Method case matters after Fetch’s normalization. The API normalizes the standard DELETE, GET, HEAD, OPTIONS, POST and PUT spellings to uppercase. It does not uppercase every arbitrary method. patch remains patch, so an Allow-Methods value of PATCH does not grant it. Request construction rejects CONNECT, TRACE and TRACK, and rejects method strings that are not valid HTTP tokens. A server’s routing rules can impose further restrictions.
The request-header safelist, exactly
Every candidate header value must first fit in 128 bytes. This is a byte-string limit, not 128 Unicode code points or a limit on the whole header line. Header names compare without ASCII case. Accept permits many values, but rejects CORS-unsafe bytes. Accept-Language and Content-Language have a tighter character set. Content-Type must satisfy a byte test and parse to one of three MIME essences. Range has its own single-range parser.
| Name | Additional value rule | Examples |
|---|---|---|
| Accept | No CORS-unsafe request-header bytes | text/html,*/* passes; text/html;v="1" fails |
| Accept-Language, Content-Language | Only ASCII letters, digits, space and * , - . ; = | en-US, fr;q=0.8 passes; underscore or tab fails |
| Content-Type | No unsafe bytes; parsed MIME essence is form-urlencoded, multipart/form-data or text/plain | text/plain;charset=UTF-8 passes;application/json fails |
| Range | One byte range with a nonempty start; end, if present, is not smaller | bytes=0-499 passes; bytes=-500 or multiple ranges fail |
The unsafe bytes are controls below 0x20 except horizontal tab, DEL (0x7f), and the punctuation " ( ) : < > ? @ [ \ ] { }. This explains an easily missed distinction: an unquoted Content-Type parameter can pass, while a quoted parameter fails because of the quote bytes, even when its MIME essence is text/plain. MIME type and subtype compare without ASCII case. The Content-Type test parses that value directly; it does not search a list for whichever type would be convenient.
Authorization is absent from this list, so our request needs a preflight even if we stop sending JSON. Changing only the body does not change that. Changing JSON to text/plain just to avoid OPTIONS can also undermine a server that relies on strict media-type validation as part of its CSRF defence. Pick the right representation and configure permission for it.
The browser does not treat its own Cookie, Origin and Sec-Fetch headers as arbitrary author headers that need to appear in Allow-Headers. Those names are protected by the request guard. Script cannot smuggle an unrelated Origin into the request to borrow another page’s grant. A bare new Headers() object is more permissive than a Request’s guarded headers, which is why constructing the actual Request is the useful local comparison.
Classify the request before it leaves
Preflight required
POST is safelisted. These headers are not: authorization, content-type.
content-type: application/json authorization: Bearer demo
OPTIONS announces: authorization,content-type
JSON and Authorization each require permission. Credentials alone do not trigger preflight.
Constructs a real Request locally and sends nothing. Fixed URL, no upload streams or redirects; the browser check compares normalization.
There is also a 1,024-byte total
Fetch walks the internal header list, collecting unsafe names. For entries that individually pass the safelist test, it sums their value lengths. If that sum is greater than 1,024 bytes, it adds all those potentially safe names to the unsafe set too. The final result is a sorted, lowercase set. Exactly 1,024 passes this aggregate test; 1,025 does not. This total is separate from the 128-byte test on each entry.
Duplicate handling matters here. An internal header list may retain separate entries, while getting or iterating headers combines matching values with comma-space. If a value is already combined before the safelist test, the combined length and grammar are what matter. Two Content-Type entries cannot be treated as independent media-type alternatives by a permissive server parser. The browser-visible combined text should make that ambiguity conspicuous.
The safelist has a total byte budget
8 × 128 = 1,024 bytes
0 bytes 1,536 bytes
Each value passes 128 bytes. The total is exactly 1,024: accept is still safelisted in this internal header list.
Fetch tests individual internal entries before summing. Headers iteration combines duplicates with comma-space; a single combined value can fail 128 bytes earlier.
These rules describe ordinary fixed-body calls like ours. A streaming upload can set Fetch’s use-CORS-preflight flag even when the visible method and headers look safelisted. Other APIs can request preflight too. Browser-specific restrictions can be stricter in some cases, so the primary reference isFetch’s safelisted request-header algorithm, itsunsafe-name algorithm, and the browser you deploy to.
Preflight follows the effective request’s method, header values and Fetch flags. It is not a synonym for “uses cookies.”
Two requests, two CORS checks
The browser now knows our author request needs permission. It sends OPTIONS to the same URL, https://api.example/orders. The request carries the page’s Origin, announces POST in Access-Control-Request-Method, and lists the unsafe header names in Access-Control-Request-Headers. It does not send the JSON order, the bearer token value, or the session cookie. The announcement is about the shape of a future request.
The unsafe names are lowercased, sorted and joined with commas:authorization,content-type. Names in the server’s response list compare without ASCII case. Methods compare as methods, with case preserved after the client’s normalization. The browser supplies Origin; your JavaScript should not try to manufacture it. A server needs to answer OPTIONS before a cookie-based login requirement rejects it.
A failed first check stops the order. A failed second check hides its reply.
Origin + requested method + unsafe header names; no session cookie
Browser checks origin, credentials, status, methods and headers
Authorization value and eligible cookies travel now
Browser repeats the origin/credentials check before exposing the reply
The CORS check is smaller than the preflight check
The core CORS check first gets Access-Control-Allow-Origin from the response header list. A missing field fails. If credentials mode is not include, the exact value * succeeds. Otherwise, the value must exactly equal the serialized requesting origin. There is no comma-separated list of permitted origins in this field. There is no suffix matching, path matching or regular expression in the browser’s comparison.
When credentials mode is include, one more condition applies: Access-Control-Allow-Credentials must be exactly true. The value is case-sensitive. True, 1, a quoted string, or duplicate fields combined into true, true do not pass. These rules use the request’s credentials mode, even when the cookie jar happens to be empty. An API cannot make a credentialed wildcard valid by observing that no Cookie header arrived.
The browser applies that core check to the preflight response using theoriginal request’s credentials mode. This is a subtle but necessary distinction: OPTIONS itself travels without cross-origin credentials, yet it must grant the access the eventual credentialed POST will need. After the core check succeeds, the preflight still needs an HTTP ok status, 200 through 299, and valid method/header permission lists.
What must the permission lists contain?
For a non-safelisted method, Access-Control-Allow-Methods must include the method, or a usable wildcard. Our method is POST, which is already safelisted, so the field may be absent even though the headers triggered preflight. Including POST is common and can make the intent easier to read; it is not necessary for this exact request. A PUT variant needs an explicit PUT grant when credentials mode is include.
Access-Control-Allow-Headers must grant the unsafe names. With credentials mode include, * is a literal header name, not a wildcard. With other credentials modes it can stand for unsafe header names, exceptAuthorization. Authorization always needs its own explicit entry. A wildcard in Allow-Methods has the same credential-dependent expansion rule. A wildcard in Expose-Headers follows that rule too. Allow-Origin’s wildcard is a separate check.
The lists use HTTP token grammar. Empty list elements are ignored, but quotes, spaces inside a token, and semicolon-separated names are not valid alternatives. Duplicate list fields combine, which is useful for Allow-Headers. Duplicate Allow-Origin fields combine too, but the result is no longer a single matching origin. Treating every CORS field as “a list of strings” is a parser bug.
Be the server. Let the browser decide.
1. OPTIONS sent without cookies; Access-Control-Request-Method: POST; Access-Control-Request-Headers: authorization,content-type.
2. Preflight origin, credentials, status, method and headers passed.
3. Cache grants stored for at most 600 seconds.
4. POST sent to https://api.example/orders.
5. Response exposed to JavaScript after the main CORS check.
Preview · simulation has not populated the cache yet
Each allowed method or header gets a grant. The response body is never stored here.
Ready. Simulate twice to see the second request skip OPTIONS. JSON and Authorization remain fixed.
Fixed-body, direct HTTP requests; redirects, upload streams and transport failures are outside this model. Cookie eligibility is explored separately below.
The smallest grant for this request
The following two responses are sufficient at the CORS layer. The first answers OPTIONS; the second answers POST. The actual API must also authenticate the user and authorize the order. The example marks the personalized main response private and uncacheable. CORS does not itself prevent a shared proxy from caching a personalized response.
HTTP/2 204
access-control-allow-origin: https://app.example
access-control-allow-credentials: true
access-control-allow-headers: authorization, content-type
vary: Origin
HTTP/2 200
access-control-allow-origin: https://app.example
access-control-allow-credentials: true
content-type: application/json
vary: Origin
cache-control: private, no-store
{"order":42}Notice the repeated Allow-Origin and Allow-Credentials on the main response. A successful OPTIONS response does not grant permission to read a later response that lacks those fields. Put the fields on error responses too when the allowed app needs to read them. With valid CORS, a 401 or 500 resolves fetch with that HTTP status; your code checks response.ok. Without valid CORS, fetch rejects with a TypeError and the application cannot inspect the status or body.
The preflight cache stores permission
Access-Control-Max-Age can retain grants for later requests. Fetch defaults to five seconds when the value is missing or invalid, then applies a browser-imposed cap. Chromium’spreflight result implementationcaps at two hours. Firefox’sCORS listener implementationcaps at 86,400 seconds, one day. These are implementation limits, not a promise that entries survive until expiry; the browser may evict earlier.
TheFetch preflight cacheincludes the network partition key, serialized origin, URL, credentials support, and individual method or header-name grants. It is separate from the HTTP response cache. A new query string is a new URL. A grant stored with credentials support can match a later non-include request; a grant stored without it cannot match an include request. A changed token value does not by itself require a new header-name grant, but every main request still needs valid authentication. A stored star expands only when that entry was created without credentials support. A star stored for an include request stays a literal star, even when a later request omits credentials. This distinction also applies when refreshing a matching grant’s expiry, as inChromium’s preflight result.
A cached permission can outlive a server configuration change. Editing the OPTIONS response alone does not revoke an existing browser grant immediately. The main endpoint must enforce access on every request. Conversely, changing response fields in the lab will not erase its simulated grants until you clear them, expire them, or a network error on this preflighted path clears matching entries. That includes a failed preflight, not only a failed main CORS check. Working POST, failed PUT preflight, then POST again must send a fresh OPTIONS request. Grants for other URLs or partitions remain intact. Use the cache controls deliberately when diagnosing a change.
Redirects change more than the URL
Answer a preflight at the URL the browser requested. An OPTIONS reply must have an ok status; a 301, 302, 303, 307 or 308 is not permission, even with CORS fields. The preflight algorithm uses the network path directly and does not follow that Location to discover a grant. A trailing-slash redirect or a redirect to a login page can therefore stop the order before POST. Use the canonical endpoint in the app and have it answer OPTIONS directly. SeeCORS-preflight fetch.
Redirecting the actual POST is a different operation. With the default redirect mode, follow, a redirect response on the CORS path must itself pass the CORS check before Fetch follows it. The destination is fetched under the resulting method, headers and credentials rules; it may need its own preflight and its response must pass CORS too. An earlier grant for api.example/orders does not authorize a different URL. The direct request lab above stops at a single response; these redirect cases are described separately here.
Status matters to the order. A 301 or 302 rewrites POST to GET; a 303 rewrites methods other than GET or HEAD to GET. Fetch drops the body and its body-related headers on those rewrites. A 307 or 308 preserves the method and body, provided the body can be replayed. A streaming upload without a replayable source can fail instead. Fetch also stops after 20 redirects. These are the steps inHTTP-redirect fetch.
An origin-changing redirect strips an author-supplied Authorization field. It is not automatically restored if the chain returns to the original host. Credentials mode remains the same setting, but ambient cookies are selected again for each target under domain, path, Secure, SameSite and storage policy. Include permits eligible target cookies; it does not copy api.example’s Cookie header to an arbitrary host or preserve the bearer token. Same-origin does not permit credentials on a CORS-tainted hop merely because a redirect eventually returns to the page’s origin. Cross-origin CORS redirect targets containing a username or password in the URL are rejected by Fetch’s URL-credential checks.
Why a redirect can produce Origin: null
Fetch tracks the request’s URL history, not just its current address. Starting with the second URL, compare each destination with the previous URL. If those two origins differ and the requesting page’s origin also differs from the previous origin, the redirect history becomes tainted. Even a same-site origin change can taint it. Fetch then serializes the request origin as the literal null for the Origin field and the CORS comparison. Returning to a previous address does not erase that history. The exact rules areredirect-taintand request-origin serialization.
| Actual-request URL chain | Origin sent after redirect | Author Authorization |
|---|---|---|
| api.example/orders → api.example/v2/orders | https://app.example | Retained; the redirect stays on the API’s origin |
| app.example/api → api.example/orders | https://app.example | Removed; this is an origin change, though the history is not yet tainted |
| api.example/orders → regional.example/orders | null | Removed; the request was already away from the app’s origin |
| api.example/orders → app.example/orders | null | Removed; returning to the app does not reset the history |
For a 307 from api.example to regional.example, our JSON Content-Type remains, so the destination can receive an OPTIONS preflight with Origin: null. Authorization has been stripped. With credentials mode include, the destination would need the matching literal null grant and Allow-Credentials: true to pass CORS. Do not broaden a private API’s allowlist to every null origin to make this chain work: the same string also represents unrelated sandboxed documents. Call the final controlled API URL directly or route the integration through your own server.
Redirect mode error rejects a redirect instead of following it. Manual mode gives page JavaScript an opaque-redirect response, with status 0 and hidden headers; it does not expose Location as a way around CORS. Redirects can also fail earlier for mixed content or browser-specific restrictions. When diagnosing an order, inspect both the preflight and the actual-request redirect chain in DevTools before retrying a mutation.
Vary belongs to another cache
If a server chooses Allow-Origin based on the incoming Origin, it should sendVary: Origin so an HTTP cache separates those representations. That does not populate the preflight cache, and Max-Age does not authorize shared caching of an order body. A proxy that caches a dynamically tailored preflight response may also need to vary on Access-Control-Request-Method and Access-Control-Request-Headers. Keep personalized data out of shared caches unless the representation and cache key are deliberately safe.
const allowedOrigins = new Set(["https://app.example"]);
const origin = req.headers.origin;
res.vary("Origin"); // append; preserve other Vary fields
if (typeof origin === "string" && allowedOrigins.has(origin)) {
res.setHeader("Access-Control-Allow-Origin", origin);
res.setHeader("Access-Control-Allow-Credentials", "true");
if (req.method === "OPTIONS") {
res.setHeader("Access-Control-Allow-Headers", "authorization, content-type");
res.setHeader("Access-Control-Max-Age", "600");
res.status(204).end();
return;
}
}
// OPTIONS does not require a logged-in cookie.
// Main requests still need authentication, authorization and CSRF checks.
next();These are the steps inCORS-preflight fetchand the CORS check. Browser console strings are diagnostic UI and can change; the lab uses their familiar style while exposing the failed algorithmic condition. Application code receives the intentionally less detailed rejection.
Preflight approves the request shape. The main response still has to grant response access, every time.
A cookie has several gates to pass
Suppose both CORS checks now pass, but the API says you are logged out. The cookie never arrived. This is a different branch of the debugging tree. A CORS grant allows response sharing; it does not tell the browser to ignore credentials mode, SameSite or its storage policy. Each gate can independently withhold the API session.
The Fetch default is credentials: "same-origin". That allows ambient credentials for same-origin requests, not for our cross-origin API call.omit excludes them. include permits cross-origin credentials and response credential processing, subject to cookie and browser policy. These modes also govern other kinds of ambient credentials, such as HTTP authentication state and TLS client certificates; implementation exceptions around preflight client certificates exist.
An Authorization field explicitly supplied by your code is different from a cookie selected by the browser. Changing credentials mode to omit does not remove that author-supplied field. It still requires a header permission during preflight, and the API still sees the supplied bearer token if the main request goes ahead. Never interpret “omit” as a guarantee that a request contains no application-level secret.
Which host owns the cookie?
A host-only cookie set by api.example belongs to api.example. The app does not have to read the cookie to use it: the browser can attach it to an eligible API request. HttpOnly prevents JavaScript access through cookie APIs, while Secure restricts transmission to secure channels. Path and Domain participate in cookie selection, but Path is not an isolation boundary against hostile code on the same origin.
Prefer a host-only session cookie when you do not need to share it with subdomains. The __Host- prefix requires Secure, Path=/ and no Domain attribute in supporting browsers. A compromised sibling cannot set an equivalent broadly scoped cookie under that prefix. That hardens the session namespace; it still does not make the sibling trustworthy enough for CORS or prevent every same-site attack.
SameSite asks about a site, not an origin
Strict cookies are withheld on cross-site requests. Lax cookies have a limited cross-site exception for top-level navigation using a safe method, such as following a GET link. A background fetch is not a top-level navigation. A cross-site fetch GET therefore does not qualify merely because GET is safe. None allows cross-site use at the SameSite layer and requires Secure when stored. See6265bis cookie retrieval.
For our literal app.example to api.example call, a Lax session will be withheld. For app.shop.example to api.shop.example, the two hosts can be same-site even while CORS considers them cross-origin. In a top-level app context with no cross-site ancestors, a suitable API cookie can pass SameSite on that sibling request. This does not mean the app’s own host-only cookies go to the API. Cookie host matching and site matching are separate questions.
The site-for-cookies calculation also considers context. A same-site-looking URL inside a cross-site ancestor chain is not interchangeable with an ordinary top-level app. Redirect chains and navigations introduce more detail. Treat a URL-only comparison as a useful first step, not the complete cookie retrieval algorithm. The lab below fixes the ancestor context so you can isolate the gates that matter to our checkout.
Will the API’s session cookie travel?
1. Credentials mode include: eligible for cross-origin cookies.
2. Cross-site fetch POST: Lax cookie withheld.
3. No Cookie header from this candidate cookie.
Cookie withheld by SameSite=Lax. A successful CORS check would not change this.
Default uses 6265bis/Chromium policy, not Firefox release. Assumes an unexpired, host/path-matching cookie over HTTPS in a top-level app, without redirects. Partitioned mode assumes a matching stored key; navigation uses HTML credentials.
Default is not exactly an explicit Lax attribute
6265bis assigns cookies without a recognized SameSite value a Default flag. Its baseline enforcement is Lax-like. User agents may apply a compatibility rule called Lax-allowing-unsafe to recently created Default cookies on top-level navigations, including unsafe methods. The draft suggests two minutes as a reasonable age limit. That exception does not turn a background cross-site fetch POST into a permitted cookie request, and it does not apply to cookies explicitly marked Lax. The lab lets you choose that compatibility policy rather than silently treating it as universal.
Chromium applies Lax-by-default to an unspecified SameSite attribute, including its 120-second compatibility exception for top-level cross-site POSTs. Firefox release does not enable that default: itsnetwork.cookie.sameSite.laxByDefault preference is false. Firefox’s Total Cookie Protection is a separate storage restriction, not an equivalent SameSite rule. The lab’s Default choice models the 6265bis/Chromium policy, not Firefox release behavior.
Safari changed too. A WebKit maintainer confirmed Lax-by-default for iOS 18 and macOS Sequoia in September 2024. Expect that policy on those newer OS families, but verify the actual Safari/OS combination: cookie handling also lives in Apple’s system networking frameworks. The Chromium two-minute exception is not a portable promise. Set SameSite explicitly, then check storage policy independently.
Source check: 15 November 2026. SameSite defaults, storage policy and CHIPS are independent columns; settings, managed profiles and embedded WebViews can differ.
| Browser | SameSite omitted | Third-party cookie policy | CHIPS / Partitioned |
|---|---|---|---|
| Chromium / Chrome | Lax-by-default, with the 120-second Lax-allowing-unsafe exception for a recent unspecified cookie on a top-level cross-site POST. Chromium FAQ, checked 15 Nov 2026. | Retains user choice; no universal third-party-cookie removal. Incognito blocks unpartitioned third-party cookies by default. 22 Apr 2025 decision; Incognito policy, checked 15 Nov 2026. | Supported by default in Chrome 114+. Implementation status, checked 15 Nov 2026. A partitioned cookie is not an unpartitioned-login exception. |
| Firefox release | Does not enable Lax-by-default: the release preference network.cookie.sameSite.laxByDefault is false. Explicit SameSite attributes and other cookie checks still apply. Release preferences, checked 15 Nov 2026. | Total Cookie Protection partitions state per top-level site by default in Standard mode; tracker blocking and storage-access exceptions also apply. Mozilla policy, updated 20 May 2025. | Enabled in release source: network.cookie.CHIPS.enabled is true. This opt-in mechanism is distinct from automatic Total Cookie Protection. Release preferences, checked 15 Nov 2026. |
| Safari / Apple platforms | Lax-by-default was introduced with iOS 18 and macOS Sequoia, according to a WebKit maintainer’s 4 Sep 2024 confirmation. Expect that on those newer OS families; verify the target OS/build. Do not assume Chromium’s two-minute grace rule. | Blocks unpartitioned cross-site cookies by default; eligible Storage Access grants can restore unpartitioned access. WebKit policy, 24 Mar 2020; partitioned use is described in the 26.2 release notes. | Restored in Safari 26.2, released 12 Dec 2025. Initially shipped in 18.4 and withdrawn in 18.5. WebKit 26.2 release notes. Older OS/browser combinations need separate verification. |
None is not a third-party-cookie bypass
A cookie can pass SameSite=None and still be blocked or partitioned by browser privacy policy. Chrome’s rollout history is especially easy to misremember. Google’s22 April 2025 announcementretained user choice through existing settings and dropped a planned standalone third-party-cookie prompt. Do not describe an earlier phase-out schedule as an accomplished universal removal. The user’s browser profile, private mode and policy can still change the outcome.
For state that should be separate for each embedding top-level site,CHIPS adds the Partitioned attribute. The cookie is associated with a partition key that includes the top-level site; it does not become one globally shared API login. A cookie created in one partition is not automatically available in another. It still needs Secure and suitable SameSite attributes. Chrome documents thepartition key and cross-site ancestor informationused by its cookie store.
Set-Cookie: __Host-session=opaque-token; Path=/; Secure; HttpOnly; SameSite=None
# A separate partitioned session, scoped to the embedding top-level site:
Set-Cookie: __Host-embed=opaque-token; Path=/; Secure; HttpOnly; SameSite=None; PartitionedTheStorage Access APIoffers an embedded document a way to request access to unpartitioned state, under browser permission and eligibility rules. It is not an HTTP header the API can add to force cookie access, and it does not waive CORS. An architecture that depends on a cross-site session should plan its login and embedding flows around those browser rules instead of hoping one successful fetch changes them.
For a deployment you control, the simplest dependable configuration may be a same-origin backend route, or same-site app and API hosts with explicit CORS. For our cross-site example, a None cookie may be necessary, but it remains subject to storage policy. If the bearer token is the actual authentication mechanism, decide whether the cookie is needed at all. Reducing ambient credentials also reduces the amount of authority an unwanted request can borrow.
Cookie delivery is the intersection of credentials mode, cookie scope, SameSite and storage policy. Passing one gate does not bypass the others.
CORS is one boundary among several
The order works. That still leaves several other cross-origin questions: may another site embed your API response as a resource, may your app depend on resources that have not opted in, and may a popup keep a relationship with its opener? These questions are answered by different policies. Their names are similar because they all describe boundaries between origins; their jobs are different.
Cross-Origin-Resource-Policy, CORP, is a response-side restriction on no-cors resource use. A resource can request same-origin or same-site use, or explicitly permit cross-origin use. For example, a private image endpoint can keep unrelated pages from embedding it. CORP is not an alternate spelling of Allow-Origin and does not grant a CORS fetch access to a JSON response. Its check is specified underFetch’s CORP header.
Cross-Origin-Embedder-Policy, COEP, is a document policy. With require-corp, a document requires appropriate approval for cross-origin resources: CORS-approved loads or no-cors resources that pass resource policy. The credentialless value takes another route for eligible no-cors loads, omitting their credentials under the policy’s rules. Neither setting teaches an arbitrary API to accept our JSON POST. The API still needs its CORS grant.
Cross-Origin-Opener-Policy, COOP, governs browsing context group relationships. A same-origin policy can separate a document from a cross-origin opener. This limits window relationships that can otherwise create security and side-channel exposure. It can also affect payment or login flows that expect a popup to communicate through its opener. Roll out a document policy with those flows in mind.
Different policies answer different questions.
Allow-Origin and, for include, Allow-Credentials
same-origin / same-site / cross-origin
require-corp, or credentialless for eligible no-cors loads
same-origin separates cross-origin openers
Sec-Fetch-Site / Mode / Dest; explicit client exceptions
A conventional cross-origin isolation configuration combines COOP: same-origin with COEP: require-corp in a secure context. Subject to the platform’s other conditions and permissions policy, this enables capabilities such as SharedArrayBuffer. Test crossOriginIsolated in the document that needs them. Setting only one header, or setting them on a JSON API response instead of the relevant document, does not establish the document’s isolation. The policies live inHTML’s COOPandCOEP definitions.
Cross-Origin-Opener-Policy: same-origin
Cross-Origin-Embedder-Policy: require-corp
# On a cross-origin image that explicitly permits no-cors embedding:
Cross-Origin-Resource-Policy: cross-originTell the server how the request was made
The browser can also supply Fetch Metadata. Sec-Fetch-Site describes the relationship to the target: same-origin, same-site, cross-site, or none for contexts such as a directly initiated navigation. Sec-Fetch-Mode describes the request mode. Sec-Fetch-Dest describes its destination: a fetch call uses empty, an image uses image, and a document navigation uses document. Sec-Fetch-User, when present for an activated navigation, is the structured boolean ?1.
Our HTTPS fetch normally carries cross-site, cors and empty. The same-site shop.example variant changes Site but retains cors and empty. These fields are protected from page JavaScript by the Sec- prefix. They describe browser context, not user identity. A command-line client can construct arbitrary HTTP headers, so the server still needs authentication. A reverse proxy should preserve the fields rather than replace them with guessed context.
A resource isolation policy can reject requests whose context makes no sense for the route. A JSON order endpoint has no reason to serve an image load or a top-level document navigation. But a blanket “reject all cross-site” rule would break our intentional cross-site SPA. Make that exact app origin an explicit exception, keep same-site subdomains untrusted unless you have a reason to trust them, and decide how older or non-browser clients without metadata will be authenticated.
What does the server know before processing the body?
Sec-Fetch-Site: cross-site Sec-Fetch-Mode: cors Sec-Fetch-Dest: empty Origin: https://app.example
Allow the explicitly trusted API client, then authenticate the request.
The cross-site SPA is an explicit exception. The same headers do not grant an arbitrary image or form access.
Target: https://api.example/orders. The same-site source is untrusted.api.example; the same-origin source is api.example. No redirects. “none” represents a direct user navigation, not an Origin value. Sec-Fetch-User is omitted unless navigation has user activation.
// Policy for this JSON API. Use after a route match for /orders.
const site = req.headers["sec-fetch-site"];
const mode = req.headers["sec-fetch-mode"];
const dest = req.headers["sec-fetch-dest"];
const trusted = req.headers.origin === "https://app.example";
res.vary("Sec-Fetch-Site");
res.vary("Sec-Fetch-Mode");
res.vary("Sec-Fetch-Dest");
res.vary("Origin");
if (mode && (mode !== "cors" || dest !== "empty")) {
return res.status(403).end();
}
if (site && site !== "same-origin" && !trusted) {
return res.status(403).end();
}
// Missing metadata may be a non-browser client: authenticate it normally.
// This resource policy does not replace authentication or CSRF protection.
next();The snippet varies HTTP cache representations on the request-context fields it uses. It deliberately leaves missing metadata to normal authentication and CSRF protection, so older clients have a defined path. You could choose a stricter policy for a browser-only route. The important part is choosing deliberately, logging rejected contexts, and testing the legitimate login, preflight and API paths before enforcement. SeeFetch Metadata’s Site algorithmand itsdeployment considerations.
Local networks have an additional gate
A public web page talking to a router or localhost raises an extra problem: your laptop can reach addresses the page’s operator cannot. Chrome previously pursued Private Network Access with additional preflights and server opt-in headers. That effort was put on hold and replaced by Local Network Access permission work. Do not copy an old PNA tutorial and assume it describes the shipped path.
Chrome 142’s release notesdescribe a secure-context permission gate for public-to-local or loopback requests, and local-to-loopback requests. TheLNA announcementexplains the change from PNA. Permission to contact the local network is an additional condition; it does not grant permission to read a cross-origin reply. This dive’s api.example is an ordinary public HTTPS API, so its simulation does not invoke that local-network permission path.
Ask which boundary failed: response sharing, embedding, opener relationships, request context or local-network permission.
Who did your allowlist actually trust?
A broken CORS configuration often starts with a helpful intention: “Our frontend is blocked; reflect the Origin so it works.” The browser then correctly enforces the server’s dangerously broad grant. Most CORS vulnerabilities are server trust bugs, not a browser forgetting to compare origins.
For an attack, separate the capabilities involved. The attacker can host a page and run JavaScript under its origin. They can make a victim visit it. They do not automatically know the SPA’s bearer token, and they cannot set an arbitrary Cookie header in a browser request. To steal private orders, they need a readable endpoint with usable victim authority, such as a cookie-authenticated session whose cookie rules permit that request.
This distinction matters for our combined JSON, Authorization and cookie example. A server that strictly requires an unknown bearer token is not exposed merely because it reflects Origin. A different endpoint that accepts the ambient session cookie might be. CORS review should examine the endpoint’s actual authentication choices and response sensitivity, not conclude “account takeover” from a header pair alone. Broad reflection is still the wrong grant for a private API because it needlessly hands response access to arbitrary origins.
Reflection grants the attacker their own origin
Suppose the server copies every incoming Origin into Allow-Origin and always sends Allow-Credentials: true. A request from attacker.example receives a grant for attacker.example. The browser compares those identical strings and passes. The attacker never needs to impersonate app.example. If their request shape needs preflight, both the OPTIONS handler and main handler must be permissive for that path; a safelisted cookie-authenticated read may not need OPTIONS at all.
A safer server checks a small set of exact serialized origins that it controls. It emits a grant only when the input matches one of them. It does not return a comma-separated array, copy an arbitrary request string into the response, or allow every origin because “we already validate the token.” Authentication answers who the user is; the allowlist answers which web principal can read a response using that user’s authority.
Find the trust bug
res.setHeader("Access-Control-Allow-Origin", req.headers.origin);
res.setHeader("Access-Control-Allow-Credentials", "true");Read the policy, choose an origin, then make a prediction.
A browser trusts the server’s CORS grant. Find which origin the server accidentally trusted.
Exploitation needs usable victim credentials; the attacker does not automatically know the app’s bearer token. Policy checks run locally.
String matching can widen the boundary
A check such as origin.endsWith("app.example") acceptshttps://evil-app.example. A regular expression with an unescaped dot can match an arbitrary character; an unanchored expression can accept a trusted-looking substring in an attacker’s longer host. Origins also contain a scheme and potentially a nondefault port. A host-only match can accidentally approve HTTP or an untrusted port. Parse what you intend to compare and keep the comparison small enough to audit.
Even a syntactically correct “every subdomain of shop.example” rule has consequences. A forgotten DNS entry, tenant-controlled site, hosted documentation system or vulnerable sibling app can become an approved reader. Same-site does not mean equally trusted. A compromised subdomain can also be same-site for cookies, which can remove a SameSite defence that would block an unrelated attacker site. Narrow origin grants reduce that shared trust.
The null string does not name one application
Approving Allow-Origin: null can make local demos convenient, but it grants any requesting opaque origin that serializes to null. An attacker can create such a context using an iframe sandbox. The string is not a stable identity that proves the request came from your file, extension or development tool. Give an application a real, controlled origin instead of making null a production credentialed principal.
The browser’s core algorithm can legitimately accept the literal null when the request origin serializes that way. That is exactly why the server must avoid interpreting it as one privileged application. Do not confuse this literal field value with the algorithm’s internal null result for a missing header. Missing Allow-Origin always fails; Allow-Origin containing the bytes n-u-l-l can match an opaque requester.
JSONP grants code execution, not filtered data access
Classic cross-origin script embedding predates CORS. JSONP exploited that channel by returning a JavaScript call such asreceiveOrders({"order":42}). The embedding page defines the callback and receives the data when the script executes. A sensitive JSONP endpoint can therefore disclose data without an ordinary CORS fetch. Removing Allow-Origin from it does not close that intentionally executable interface.
It is also a trust decision in the other direction: a site including a remote classic script gives that script execution in the including page’s environment. A CORS grant for a JSON response grants a narrower capability. Avoid treating a script tag as a harmless network workaround for a blocked private API. Use a real JSON API, a deliberate CORS policy, correct Content-Type, and nosniff where appropriate.
When reviewing our order endpoint, enumerate the approved origins, verify that all remain under your control, and test both preflight and main error responses. Then ask what an unwanted request can do even if its response stays unreadable. A sound CORS allowlist and CSRF protection complement each other. Neither replaces per-user authorization of the order itself.
The server’s allowlist is a trust decision about web origins. Make it as narrow as the actual application relationship.
Permission becomes headers and frames
At the bottom of this story there is no CORS transport. OPTIONS and POST are ordinary HTTP requests with particular fields. They can share an existing HTTP/2 connection to api.example. The browser waits for permission before starting the dependent main request; HTTP/2 multiplexing does not eliminate that dependency.
HTTP/2 represents a request’s method, scheme, authority and path as pseudo-header fields. The preflight’s method is OPTIONS and its path is /orders. Its Origin identifies the requesting app. Access-Control-Request-Headers lists names only. The bearer token and eligible session cookie belong to the later POST. Sec-Fetch fields describe the initiation context on these secure requests.
The familiar text HTTP/2 204 is a readable transcription of a response, not a literal HTTP/1-style status line on this wire. HTTP/2 encodes header fields in an HPACK header block carried by HEADERS and, if needed, CONTINUATION frames. A response uses the :status pseudo-header. Our generated example uses deliberately plain HPACK literals so that every displayed byte can be traced back to a displayed field.
From header fields to actual frame bytes
Decoded header fields
:method: OPTIONS :scheme: https :authority: api.example :path: /orders origin: https://app.example accept: */* access-control-request-method: POST access-control-request-headers: authorization,content-type sec-fetch-site: cross-site sec-fetch-mode: cors sec-fetch-dest: empty
9-byte HEADERS frame header
00 01 14 01 05 00 00 00 01
Payload 276 bytes · type 1 · flags 0x05 · stream 1
Length · type · flags · reserved bit + stream ID
HPACK header block · literal fields without indexing or Huffman coding
00 07 3a 6d 65 74 68 6f 64 07 4f 50 54 49 4f 4e 53 00 07 3a 73 63 68 65 6d 65 05 68 74 74 70 73 00 0a 3a 61 75 74 68 6f 72 69 74 79 0b 61 70 69 2e 65 78 61 6d 70 6c 65 00 05 3a 70 61 74 68 07 2f 6f 72 64 65 72 73 00 06 6f 72 69 67 69 6e 13 68 74 74 70 73 3a 2f 2f 61 70 70 2e 65 78 61 6d 70 6c 65 00 06 61 63 63 65 70 74 03 2a 2f 2a 00 1d 61 63 63 65 73 73 2d 63 6f 6e 74 72 6f 6c 2d 72 65 71 75 65 73 74 2d 6d 65 74 68 6f 64 04 50 4f 53 54 00 1e 61 63 63 65 73 73 2d 63 6f 6e 74 72 6f 6c 2d 72 65 71 75 65 73 74 2d 68 65 61 64 65 72 73 1a 61 75 74 68 6f 72 69 7a 61 74 69 6f 6e 2c 63 6f 6e 74 65 6e 74 2d 74 79 70 65 00 0e 73 65 63 2d 66 65 74 63 68 2d 73 69 74 65 0a 63 72 6f 73 73 2d 73 69 74 65 00 0e 73 65 63 2d 66 65 74 63 68 2d 6d 6f 64 65 04 63 6f 72 73 00 0e 73 65 63 2d 66 65 74 63 68 2d 64 65 73 74 05 65 6d 70 74 79
No DATA frame: OPTIONS has no request body.
OPTIONS ends stream 1 in HEADERS: END_HEADERS | END_STREAM = 0x05. No cookies or bearer token are on the preflight.
Generated HTTP/2 illustration with literal HPACK; connection setup and extra browser headers omitted. POST assumes an eligible session cookie.
Nine bytes describe a frame
The frame header starts with a 24-bit payload length, then an 8-bit type, 8 bits of flags, and a reserved bit plus 31-bit stream identifier. The length excludes those nine framing bytes. HEADERS has type 0x01. END_HEADERS is flag 0x04. A bodyless OPTIONS request can also set END_STREAM, 0x01, so its flags byte is 0x05. The POST’s HEADERS use 0x04, followed by a DATA frame with END_STREAM to finish its body.
Client-initiated streams have odd identifiers, so 1 and 3 are valid example streams. They are independent HTTP requests on one connection, not two phases of a single stream. The server responds on the corresponding stream. Other streams may carry unrelated requests while these exchanges happen. A blocked preflight means no order stream is started for that fetch.
The HPACK illustration encodes each field without indexing: a zero byte introduces a literal name, followed by length-prefixed name and value byte strings. The strings are ASCII here, with Huffman coding disabled, so the hexadecimal payload is easy to decode. Real browsers commonly use static-table indexes, dynamic-table state and Huffman coding; the bytes are connection-dependent. These fixtures are valid illustrative bytes, not a claim about the exact compression choices of your browser. SeeHPACK literal fieldsandHTTP/2 frame format.
TLS encrypts those frames on the connection. A packet capture outside the browser ordinarily sees TLS records rather than readable CORS fields. DevTools presents decoded HTTP metadata after the browser has processed the protocol layers. Seeing a response in DevTools does not imply the page was allowed to receive it: privileged diagnostics can show more than the JavaScript response interface.
Preflight adds a dependency, usually one round trip
On an already established connection, a successful uncached preflight adds an OPTIONS round trip before the main request. If network RTT is R and we ignore server work and body transfer, the first request needs about 2R instead of R. The next request can cost R while the required grants remain cached. Connection setup, queueing and server processing can add more; they are not intrinsic fixed CORS overhead.
What does one extra round trip cost?
20 fetches at 80 ms RTT: 1 preflight, 20 main requests, 1,680 ms total serialized network wait. Preflight overhead averages 4 ms per fetch.
Warm connection; zero server work and transfer time; serial requests scheduled ten seconds apart. Cache age measured at each start, no eviction. Bars share a zero origin; scale maximum is the uncached total for the selected count and RTT.
For twenty calls at 80 ms RTT with one preflight, the main requests consume 1,600 ms of serialized network wait and OPTIONS adds 80 ms. That is 4 ms of average overhead per call, even though the first call pays all 80 ms. This is why measuring only a warm request can hide the cold-path delay. Conversely, a page with many distinct URLs or header combinations may receive fewer reusable grants than a single-endpoint benchmark suggests.
You can reduce avoidable preflight work by keeping a deliberate, stable request shape and setting a sensible Max-Age. You can also move an integration behind a same-origin server route. Removing authentication, mislabelling JSON, or granting arbitrary origins to save an RTT trades away the very boundary the browser is protecting. The lowest-latency configuration still needs to express the correct trust relationship.
Where the browser enforces the decision
In Chromium, the network service contains CORS handling and the preflight machinery, alongside its HTTP loaders. The page’s renderer asks for a fetch; it does not own an unrestricted socket and decide whether to obey CORS afterwards. Thenetwork service designdescribes that process boundary, andCorsURLLoaderis a concrete implementation path.
The server sends bytes. The browser chooses which process gets them.
JavaScript cannot set Cookie, Origin or Sec-Fetch-*
Owns HTTP connections; can reject before the main request
Permitted body and headers are exposed; failures become network errors
HTTP errors with valid CORS resolve; CORS failures reject with TypeError
Opaque resource blocking adds another layer for no-cors resources. CORB historically blocked selected sensitive formats from reaching an inappropriate renderer context; ORB moves toward validating which formats belong in such loads. This protects against exposure beyond the JavaScript API, including process-memory attacks. It is not a way to make an opaque JSON response readable. Chromium’sCORB/ORB implementation notesdescribe staged work, so “ORB fully replaced every CORB path in every browser” would be too broad.
Back to the order button
The debugging path is now concrete. Check the effective Request, not just the source object you passed to fetch. Inspect whether OPTIONS happened and which condition failed. Give the exact app origin permission, explicitly grant authorization and content-type, allow credentials when include is intentional, and repeat the origin/credentials grant on the main response. Keep OPTIONS independent of the session login gate. Use the right cookie design, and verify that browser storage policy permits it.
Then test the failures you want the user to see. An expired token should produce a readable 401 for the trusted app. A malformed order should produce a readable validation response. An unrelated origin should receive no response-sharing grant. An unwanted authenticated action should be rejected before state changes, even when its response would be unreadable. Once those behaviors line up, the browser is enforcing the application’s intended boundary instead of standing in its way.
The fix is a precise server grant plus independent authentication and cookie policy. The browser is enforcing who may read, not guessing which two services you own.
End of CORS · 8 levels, Idea to Machine
Where to next
Next in Web and networking · 07 of 12
WebSockets, down to the frame
Why the web needed a full-duplex pipe, how an HTTP request turns into one, and what every bit of a WebSocket frame means on top of a TCP stream.
Practical notes
CORS: a practical response-header checklist
Diagnose a blocked browser fetch by checking the origin, preflight response and credential policy. CORS controls what scripts can read; it does not authenticate a request.