CORS Playground

Learn same-origin policy, CORS, and preflight by inspecting and testing them.

ๆ—ฅๆœฌ่ชž

What you will learn

  • An origin is the combination of scheme, host, and port.
  • SOP restricts one origin from reading another origin's DOM and responses.
  • CORS lets a server grant selected cross-origin response access.
  • A preflight can stop the actual request before it is sent.

https://example.com:443 is an origin. A different scheme, host, or port means a different origin.

SOP does not make every cross-origin request disappear. It limits what JavaScript can read or manipulate.

A CORS-safelisted request can send the actual request first. Other cross-origin requests use an OPTIONS preflight.

If preflight is rejected, the actual request is not sent. A Fetch API TypeError alone cannot prove the cause.

SOP experiment

Compare direct DOM access with a same-origin iframe and a sandboxed iframe, then exchange a message explicitly.

Same-origin iframe

Sandboxed iframe

postMessage

Direct DOM access and explicit message exchange are different capabilities. The receiver must validate the sender.

Received messages

CORS decision simulator

Change request intent and response headers. The result models CORS checks; it does not send a request.

Request intent

Simulated response headers

Decision

Explanation

HTTP exchange flow

Follow OPTIONS, the actual request, and JavaScript response access for the current conditions.

    This is a learning model, not proof of network traffic. Confirm actual requests in DevTools Network or server logs.

    Response headers readable by JavaScript

    Enter the response header names, then compare them with ACEH and the credentials mode.

    Set-Cookie and Set-Cookie2 are never exposed. With credentials, * in ACEH is not a wildcard.

    Preflight cache timeline model

    This learning model assumes the same origin, URL, credentials, method, and header conditions.

      This is not a browser measurement. Implementations can impose caps or evict entries early. Confirm OPTIONS in DevTools Network.

      HTTP response cache and Vary

      Inspect normal HTTP response caching separately from the preflight cache.

      Vary affects a normal HTTP cache key. It is separate from Access-Control-Max-Age.

      CORS permission and cookie conditions

      Even when CORS succeeds, cookie attributes or browser policy may prevent a cookie from being sent.

      Domain, Path, expiry, and stored-cookie state also matter. This model cannot prove actual transmission.

      Live Fetch Lab

      This lab sends real requests only after you press Run. CSP limits destinations to the three listed origins and this site.

      Request settings

      A TypeError does not identify CORS by itself. Inspect OPTIONS and response headers in DevTools Network.

      Request / response log