What is the Cross-Origin-Resource-Policy header?
The Cross-Origin-Resource-Policy (CORP) response header lets a server say which origins or sites may load the response when the browser fetches it in no-cors mode: through an <img>, <script>, <link>, <video> or similar tag, or a fetch() with mode: "no-cors". It is defined in the WHATWG Fetch Standard and registered as a permanent field in the IANA HTTP Field Name Registry.
| Value | Who may load the response |
|---|---|
same-origin |
Only the same origin (scheme, host and port). |
same-site |
Only the same site: the same registrable domain, ignoring scheme and port, except that an http page may not load an https response under this rule. |
cross-origin |
Anyone. |
Fetch only applies the check when the response would be opaque, that is, to cross-origin no-cors requests. A cross-origin fetch() in cors mode is governed by CORS and Access-Control-Allow-Origin, and CORP does not block it. An unrecognized value, or more than one value, is ignored as if the header were absent.
CORP exists because a no-cors load pulls the response bytes into the requesting page’s process, even though the page cannot read them directly. Side-channel attacks in the Spectre family can then read that memory. CORP lets the browser refuse to load the response at all.
API Usage & Best Practices
- Send
same-originon authenticated JSON. An attacker page can point an<img>or<script>at your API, and the browser may attach the user’s cookies, depending on theirSameSiteattribute. CORPsame-originmakes the browser discard the response before it reaches the attacker’s process. Your own front end is unaffected: if it calls the API through CORS, CORP does not apply to those calls. - It does not break your cross-origin SPA. A browser app on
app.example.comcallingapi.example.comwithfetch()uses CORS mode, soCross-Origin-Resource-Policy: same-originon the API does not stop it. Get the CORS headers right and the two coexist. - Use
cross-originfor resources meant to be embedded anywhere. Public images, avatars, file downloads served from your API and anything other sites load with a tag should saycross-origin. Pages that opt into cross-origin isolation withCross-Origin-Embedder-Policy: require-corprefuse cross-originno-corsresources that lack an explicit CORP (or CORS) opt-in, so an explicitcross-originis what keeps them loadable there. - Prefer
same-origintosame-site.same-sitelets every subdomain under your registrable domain load the response, including user-content and marketing subdomains you may not fully control. Reach for it only when a sibling subdomain genuinely embeds the resource with a tag. - Machine clients ignore it. SDKs,
curland server-side callers never apply CORP. It is browser defense in depth, not access control.
Examples
Authenticated API data that should never be loaded by another site’s tags:
HTTP/1.1 200 OKContent-Type: application/jsonCross-Origin-Resource-Policy: same-originA public image served from the API, meant to be embedded on any site, including cross-origin-isolated pages:
HTTP/1.1 200 OKContent-Type: image/pngCross-Origin-Resource-Policy: cross-originCache-Control: public, max-age=86400